diff --git a/lib/class-customizer.php b/lib/class-customizer.php index 75669226..dc419b9a 100644 --- a/lib/class-customizer.php +++ b/lib/class-customizer.php @@ -375,6 +375,7 @@ public function register( $wp_customize ) { $wp_customize->add_setting( $option->getID(), array( 'default' => $option->settings['default'], 'transport' => $transport, + 'type' =>$option->settings['save_type'] ) ); } diff --git a/lib/class-option-multicheck.php b/lib/class-option-multicheck.php index 8b61acef..083831a7 100644 --- a/lib/class-option-multicheck.php +++ b/lib/class-option-multicheck.php @@ -39,13 +39,14 @@ public function cleanValueForSaving( $value ) { return array(); } if ( is_serialized( $value ) ) { + $value = unserialize($value); return $value; } // CSV if ( is_string( $value ) ) { $value = explode( ',', $value ); } - return serialize( $value ); + return implode( ',',$value ); } public function cleanValueForGetting( $value ) { diff --git a/lib/class-option.php b/lib/class-option.php index 5dce30b9..acf6defa 100644 --- a/lib/class-option.php +++ b/lib/class-option.php @@ -92,6 +92,8 @@ class TitanFrameworkOption { 'transport' => '', 'example' => '', // An example value for this field, will be displayed in a + + 'save_type' => 'option' ); /** @@ -148,9 +150,11 @@ public function getValue( $postID = null ) { } if ( $this->type == self::TYPE_ADMIN ) { - - $value = $this->getFramework()->getInternalAdminPageOption( $this->settings['id'], $this->settings['default'] ); - + if($this->settings['save_type'] == 'theme_mod'){ + $value = get_theme_mod( $this->getID(), $this->settings['default'] ); + }else{ + $value = $this->getFramework()->getInternalAdminPageOption( $this->settings['id'], $this->settings['default'] ); + } } else if ( $this->type == self::TYPE_META ) { if ( empty( $postID ) ) { @@ -167,9 +171,11 @@ public function getValue( $postID = null ) { } else { $value = $this->settings['default']; } - } else if ( $this->type == self::TYPE_CUSTOMIZER ) { + } else if ( $this->type == self::TYPE_CUSTOMIZER && $this->settings['save_type'] == 'theme_mod') { $value = get_theme_mod( $this->getID(), $this->settings['default'] ); - } + }else if($this->type == self::TYPE_CUSTOMIZER){ + $value = $this->getFramework()->getInternalAdminPageOption( $this->settings['id'], $this->settings['default'] ); + } /** * Allow others to change the value of the option before it gets cleaned @@ -199,8 +205,11 @@ public function setValue( $value, $postID = null ) { $value = $this->cleanValueForSaving( $value ); if ( $this->type == self::TYPE_ADMIN ) { - + if($this->settings['save_type'] == 'theme_mod'){ + $value = set_theme_mod( $this->getID(), $value ); + }else{ $this->getFramework()->setInternalAdminPageOption( $this->settings['id'], $value ); + } } else if ( $this->type == self::TYPE_META ) { @@ -214,11 +223,13 @@ public function setValue( $value, $postID = null ) { update_post_meta( $postID, $this->getID(), $value ); - } else if ( $this->type == self::TYPE_CUSTOMIZER ) { + } else if ( $this->type == self::TYPE_CUSTOMIZER && $this->settings['save_type'] == 'theme_mod' ) { set_theme_mod( $this->getID(), $value ); - } + }else if($this->type == self::TYPE_CUSTOMIZER){ + $this->getFramework()->setInternalAdminPageOption( $this->settings['id'], $value ); + } do_action( 'tf_set_value_' . $this->settings['type'] . '_' . $this->getOptionNamespace(), $value, $postID, $this ); @@ -256,6 +267,9 @@ public function getOptionNamespace() { } public function getID() { + if($this->type == self::TYPE_CUSTOMIZER && $this->settings['save_type'] == 'option'){ + return $this->getOptionNamespace().'_options['.$this->settings['id'].']'; + } return $this->getOptionNamespace() . '_' . $this->settings['id']; } diff --git a/lib/class-titan-framework.php b/lib/class-titan-framework.php index a69bcd21..5c205b1e 100644 --- a/lib/class-titan-framework.php +++ b/lib/class-titan-framework.php @@ -234,7 +234,7 @@ protected function getInternalAdminOptions() { // Put all the available options in our global variable for future checking. if ( ! empty( $currentOptions ) && ! count( $this->adminOptions ) ) { - $this->adminOptions = unserialize( $currentOptions ); + $this->adminOptions = $currentOptions; } if ( empty( $this->adminOptions ) ) { @@ -305,7 +305,7 @@ public function saveInternalAdminPageOptions() { // Run this first to ensure that adminOptions carries all our admin page options. $this->getInternalAdminOptions(); - update_option( $this->optionNamespace . '_options', serialize( $this->adminOptions ) ); + update_option( $this->optionNamespace . '_options', $this->adminOptions ); do_action( 'tf_save_options_' . $this->optionNamespace ); return $this->adminOptions; }