Make WordPress Core


Ignore:
Timestamp:
04/07/2016 08:58:56 PM (7 years ago)
Author:
ocean90
Message:

Customize: Harden assignment of Customizer settings transports for selective refreshable widgets

Theme support for customize-selective-refresh-widgets can be added _after_ the logic for registering the settings for incoming widgets that have been changed. This is due to themes adding the theme support in after_setup_theme which is also the action where WP_Customize_Widgets::register_settings() is called. If these both happen at priority 10, which one is called first depends on which one was added first. The other issue is that at the time that WP_Customize_Widgets::register_settings() is called at after_setup_theme, it is called before widgets_init and thus no widgets are yet registered. This means that any settings registered at this point will always have a refresh transport even if the theme supports customize-selective-refresh-widgets, since the WP_Widget instance is not visible yet to see if it supports selective refresh.

The fix: Defer WP_Customize_Widgets::register_settings() from after_setup_theme to widgets_init at priority 95 when the widget objects have all been registered. Also, ensure that the preview filter for sidebars_widgets is added before the sidebars are iterated for adding the controls.

Props westonruter.
Fixes #36389.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-setting.php

    r36645 r37166  
    205205            $this->is_multidimensional_aggregated = true;
    206206        }
     207    }
     208
     209    /**
     210     * Reset `$aggregated_multidimensionals` static variable.
     211     *
     212     * This is intended only for use by unit tests.
     213     *
     214     * @since 4.5.0
     215     * @access public
     216     * @ignore
     217     */
     218    static public function reset_aggregated_multidimensionals() {
     219        self::$aggregated_multidimensionals = array();
    207220    }
    208221
Note: See TracChangeset for help on using the changeset viewer.