Skip to content

Commit

Permalink
fix : option refresh when customizing
Browse files Browse the repository at this point in the history
  • Loading branch information
nikeo committed Jul 30, 2015
1 parent 77e41eb commit d720a84
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions inc/class-fire-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ function __construct () {
//social networks
add_filter( '__get_socials' , array( $this , 'tc_get_social_networks' ) );

//cache option when previewing
add_action( 'customize_preview_init' , array( $this , 'tc_customize_store_db_opt' ) );
//refresh the theme options right after the _preview_filter when previewing
add_action( 'customize_preview_init' , array( $this , 'tc_customize_refresh_db_opt' ) );
}


/***************************
* EARLY HOOKS
****************************/
Expand Down Expand Up @@ -256,7 +255,7 @@ function tc_generate_default_options( $map, $option_group = null ) {
function tc_get_theme_options ( $option_group = null ) {
//do we have to look in a specific group of option (plugin?)
$option_group = is_null($option_group) ? TC___::$tc_option_group : $option_group;
$saved = (array) get_option( $option_group );
$saved = empty($this -> db_options) ? $this -> tc_cache_db_options() : $this -> db_options;
$defaults = $this -> default_options;
$__options = wp_parse_args( $saved, $defaults );
//$__options = array_intersect_key( $__options, $defaults );
Expand Down Expand Up @@ -311,14 +310,16 @@ function tc_opt( $option_name , $option_group = null, $use_default = true ) {
* The purpose of this callback is to refresh and store the theme options in a property on each customize preview refresh
* => preview performance improvement
* 'customize_preview_init' is fired on wp_loaded, once WordPress is fully loaded ( after 'init', before 'wp') and right after the call to 'customize_register'
* This method is fired just after the theme option has been filtered for each settings by the WP_Customize_Setting::_preview_filter() callback
* => if this method is fired before this hook when customizing, the user changes won't be taken into account on preview refresh
*
* hook : customize_preview_init
* @return void
*
* @since v3.4+
*/
function tc_customize_store_db_opt(){
$this -> db_options = false === get_option( TC___::$tc_option_group ) ? array() : $this -> tc_cache_db_options();
function tc_customize_refresh_db_opt(){
$this -> db_options = false === get_option( TC___::$tc_option_group ) ? array() : (array)get_option( TC___::$tc_option_group );
}


Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The exceptions to this license are as follows:
* fix : anchors smooth scroll - exclude ultimate members anchor links
* changed : customize transport of the header layout setting is now 'refresh'
* improved : modernizr upgraded to the latest version
* improved : customizer preview is refreshed faster

= 3.3.28 June 25th 2015 =
* fix : re-introduce btt-arrow handling in new front js
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The exceptions to this license are as follows:
* fix : anchors smooth scroll - exclude ultimate members anchor links
* changed : customize transport of the header layout setting is now 'refresh'
* improved : modernizr upgraded to the latest version
* improved : customizer preview is refreshed faster

= 3.3.28 June 25th 2015 =
* fix : re-introduce btt-arrow handling in new front js
Expand Down

0 comments on commit d720a84

Please sign in to comment.