-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Chatfield <[email protected]>
- Loading branch information
1 parent
2326102
commit 4e7a90f
Showing
12 changed files
with
314 additions
and
764 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
lava/_classes/_extensions/lavaExtension.php → lava/_classes/_extensions/lava-extension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Default Setting | ||
* | ||
* @package Lava | ||
* @subpackage Settings_setting_ | ||
* @author Daniel Chatfield | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
|
||
class Lava_Setting_ extends Lava_Setting { | ||
|
||
} | ||
?> |
19 changes: 3 additions & 16 deletions
19
lava/_classes/_settings/lavaSetting.php → lava/_classes/_settings/lava-setting.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
/** | ||
* Lava_Settings | ||
* | ||
* @package Lava | ||
* @subpackage Settings | ||
* @author Daniel Chatfield | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class Lava_Settings extends Lava_Base | ||
{ | ||
protected $_settings = array(); | ||
protected $_setting_prefix = 'settings'; | ||
protected $_setting_types = array( | ||
'' => '', | ||
'text' => 'Text', | ||
'checkbox' => 'Checkbox' | ||
); | ||
|
||
|
||
|
||
function _construct( $setting_prefix = 'settings' ) { | ||
$this->_setting_prefix = $setting_prefix; | ||
//add the option if it doesn't exist | ||
add_option( $this->_namespace( $this->_setting_prefix ), array() ); | ||
} | ||
|
||
function _add_setting( $setting_key, $setting_type ) { | ||
if( ! $this->_setting_exists( $setting_key ) ) { | ||
if( ! array_key_exists( strtolower( $setting_type ) , $this->_setting_types ) ) { | ||
$setting_type = $this->_setting_types[ $setting_type ]; | ||
} else { | ||
$setting_type = ''; | ||
} | ||
|
||
$class_name = "Setting_{$setting_type}"; | ||
|
||
$args = array( | ||
$this->_setting_prefix, | ||
$setting_key | ||
); | ||
|
||
$this->_settings[ $setting_key ] = $this->_instantiate_class( $class_name, $args ); | ||
} | ||
|
||
$this->_set_child( $this->_settings[ $setting_key ] ); | ||
|
||
return $this; | ||
} | ||
|
||
|
||
function _get_setting( $setting_key ) | ||
{ | ||
$this->_killChild(); | ||
|
||
if( $this->_setting_exists( $setting_key ) ) { | ||
$this->_setChild( $this->_settings[ $setting_key ] ); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
function _setting_exists( $setting_key ) { | ||
if( array_key_exists( $setting_key , $this->_settings ) ) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
|
||
function _get_settings() { | ||
return $this->_settings; | ||
} | ||
|
||
function _get_settings_by_tag( $tag ) { | ||
$setting_prefix = $this->_setting_prefix; | ||
return $this->_apply_lava_filters( "_get_settings_by_tag/{$setting_prefix}/{$tag}", array() ); | ||
} | ||
|
||
|
||
|
||
function _get_settings_from_db() { | ||
return get_option( $this->_namespace( $this->_setting_prefix ) ); | ||
} | ||
|
||
function _get_setting_from_db( $setting_key, $default = null ) { | ||
$settings = $this->_get_settings_from_db(); | ||
|
||
if( array_key_exists( $setting_key, $settings ) ) | ||
return $settings[ $setting_key ]; | ||
else | ||
return $default; | ||
} | ||
|
||
function _update_settings_to_db( $settings ) { | ||
return update_option( $this->_namespace( $this->_setting_prefix ) ); | ||
} | ||
|
||
function _update_setting_to_db( $setting_key, $setting_value ) { | ||
$settings = $this->_get_settings_from_db(); | ||
$settings[ $setting_key ] = $setting_value; | ||
return $this->_update_settings_to_db( $settings ); | ||
} | ||
} | ||
?> |
Oops, something went wrong.