GC_Customize_Widgets::override_sidebars_widgets_for_theme_switch()
最后更新于:2021-11-27 11:30:21
GC_Customize_Widgets::override_sidebars_widgets_for_theme_switch()Override sidebars_widgets for theme switch.
源文件
文件: gc-includes/class-gc-customize-widgets.php
public function override_sidebars_widgets_for_theme_switch() {
global $sidebars_widgets;
if ( $this->manager->doing_ajax() || $this->manager->is_theme_active() ) {
return;
}
$this->old_sidebars_widgets = gc_get_sidebars_widgets();
add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) );
$this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset.
// retrieve_widgets() looks at the global $sidebars_widgets.
$sidebars_widgets = $this->old_sidebars_widgets;
$sidebars_widgets = retrieve_widgets( 'customize' );
add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
// Reset global cache var used by gc_get_sidebars_widgets().
unset( $GLOBALS['_gc_sidebars_widgets'] );
}