Make WordPress Core


Ignore:
Timestamp:
03/21/2016 09:58:02 PM (8 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

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

    r36889 r37040  
    394394                'reorderLabelOff'   => esc_attr__( 'Close reorder mode' ),
    395395            ),
    396             'settingTransport'     => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     396            'settingTransport'     => 'postMessage',
    397397            'phpIntMax'            => PHP_INT_MAX,
    398398            'defaultSettingValues' => array(
     
    446446            $setting_args = array(
    447447                'type'      => WP_Customize_Nav_Menu_Setting::TYPE,
    448                 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     448                'transport' => 'postMessage',
    449449            );
    450450        } elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) {
    451451            $setting_args = array(
    452452                'type'      => WP_Customize_Nav_Menu_Item_Setting::TYPE,
    453                 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     453                'transport' => 'postMessage',
    454454            );
    455455        }
     
    536536            $setting = $this->manager->get_setting( $setting_id );
    537537            if ( $setting ) {
    538                 $setting->transport = isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh';
     538                $setting->transport = 'postMessage';
    539539                remove_filter( "customize_sanitize_{$setting_id}", 'absint' );
    540540                add_filter( "customize_sanitize_{$setting_id}", array( $this, 'intval_base10' ) );
     
    544544                    'theme_supports'    => 'menus',
    545545                    'type'              => 'theme_mod',
    546                     'transport'         => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     546                    'transport'         => 'postMessage',
    547547                    'default'           => 0,
    548548                ) );
     
    571571            $nav_menu_setting_id = 'nav_menu[' . $menu_id . ']';
    572572            $this->manager->add_setting( new WP_Customize_Nav_Menu_Setting( $this->manager, $nav_menu_setting_id, array(
    573                 'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     573                'transport' => 'postMessage',
    574574            ) ) );
    575575
     
    586586                $this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array(
    587587                    'value'     => $value,
    588                     'transport' => isset( $this->manager->selective_refresh ) ? 'postMessage' : 'refresh',
     588                    'transport' => 'postMessage',
    589589                ) ) );
    590590
     
    989989     */
    990990    public function customize_preview_enqueue_deps() {
    991         if ( isset( $this->manager->selective_refresh ) ) {
    992             $script = wp_scripts()->registered['customize-preview-nav-menus'];
    993             $script->deps[] = 'customize-selective-refresh';
    994         }
    995 
    996991        wp_enqueue_script( 'customize-preview-nav-menus' ); // Note that we have overridden this.
    997992        wp_enqueue_style( 'customize-preview' );
Note: See TracChangeset for help on using the changeset viewer.