Customize: Require opt-in for selective refresh of widgets.

* Introduces `customize-selective-refresh-widgets` theme support feature and adds to themes.
* Introduces `customize_selective_refresh` arg for `WP_Widget::$widget_options` and adds to all core widgets.
* Remove `selective_refresh` from being a component that can be removed via `customize_loaded_components` filter.
* Add `WP_Customize_Widgets::get_selective_refreshable_widgets()` and `WP_Customize_Widgets::is_widget_selective_refreshable()`.
* Fix default `selector` for `Partial` instances.
* Implement and improve Masronry sidebar refresh logic in Twenty Thirteen and Twenty Fourteen, including preservation of initial widget position after refresh.
* Re-initialize ME.js when refreshing `Twenty_Fourteen_Ephemera_Widget`.

See #27355.
Fixes #35855.

Built from https://develop.svn.wordpress.org/trunk@37040


git-svn-id: http://core.svn.wordpress.org/trunk@37007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2016-03-21 21:59:29 +00:00
parent 8e41746cb1
commit f3f84d2f21
36 changed files with 695 additions and 513 deletions

View File

@@ -109,7 +109,7 @@ final class WP_Customize_Manager {
* @access protected
* @var array
*/
protected $components = array( 'widgets', 'nav_menus', 'selective_refresh' );
protected $components = array( 'widgets', 'nav_menus' );
/**
* Registered instances of WP_Customize_Section.
@@ -258,6 +258,9 @@ final class WP_Customize_Manager {
*/
$components = apply_filters( 'customize_loaded_components', $this->components, $this );
require_once( ABSPATH . WPINC . '/customize/class-wp-customize-selective-refresh.php' );
$this->selective_refresh = new WP_Customize_Selective_Refresh( $this );
if ( in_array( 'widgets', $components, true ) ) {
require_once( ABSPATH . WPINC . '/class-wp-customize-widgets.php' );
$this->widgets = new WP_Customize_Widgets( $this );
@@ -268,11 +271,6 @@ final class WP_Customize_Manager {
$this->nav_menus = new WP_Customize_Nav_Menus( $this );
}
if ( in_array( 'selective_refresh', $components, true ) ) {
require_once( ABSPATH . WPINC . '/customize/class-wp-customize-selective-refresh.php' );
$this->selective_refresh = new WP_Customize_Selective_Refresh( $this );
}
add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) );
add_action( 'setup_theme', array( $this, 'setup_theme' ) );
@@ -1730,7 +1728,6 @@ final class WP_Customize_Manager {
'autofocus' => $this->get_autofocus(),
'documentTitleTmpl' => $this->get_document_title_template(),
'previewableDevices' => $this->get_previewable_devices(),
'selectiveRefreshEnabled' => isset( $this->selective_refresh ),
);
// Prepare Customize Section objects to pass to JavaScript.
@@ -1978,14 +1975,12 @@ final class WP_Customize_Manager {
),
) ) );
if ( isset( $this->selective_refresh ) ) {
$this->selective_refresh->add_partial( 'custom_logo', array(
'settings' => array( 'custom_logo' ),
'selector' => '.custom-logo-link',
'render_callback' => array( $this, '_render_custom_logo_partial' ),
'container_inclusive' => true,
) );
}
$this->selective_refresh->add_partial( 'site_logo', array(
'settings' => array( 'site_logo' ),
'selector' => '.site-logo-link',
'render_callback' => array( $this, '_render_site_logo_partial' ),
'container_inclusive' => true,
) );
/* Colors */