Make WordPress Core

Ticket #36167: 36167.untested.diff

File 36167.untested.diff, 4.1 KB (added by westonruter, 9 years ago)
  • src/wp-includes/customize/class-wp-customize-partial.php

    diff --git src/wp-includes/customize/class-wp-customize-partial.php src/wp-includes/customize/class-wp-customize-partial.php
    index 458fa1a..759df59 100644
    class WP_Customize_Partial { 
    176176                }
    177177
    178178                if ( empty( $this->primary_setting ) ) {
    179                         $this->primary_setting = current( $this->settings );
     179                        if ( isset( $this->settings['default'] ) ) {
     180                                $this->primary_setting = $this->settings['default'];
     181                        } else {
     182                                $this->primary_setting = current( $this->settings );
     183                        }
    180184                }
    181185        }
    182186
  • src/wp-includes/js/customize-selective-refresh.js

    diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js
    index 5cf0799..9ad49d4 100644
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    3030         * @augments wp.customize.Class
    3131         * @since 4.5.0
    3232         *
    33          * @param {string} id                              Unique identifier for the control instance.
    34          * @param {object} options                         Options hash for the control instance.
    35          * @param {object} options.params
    36          * @param {string} options.params.type             Type of partial (e.g. nav_menu, widget, etc)
    37          * @param {string} options.params.selector         jQuery selector to find the container element in the page.
    38          * @param {array}  options.params.settings         The IDs for the settings the partial relates to.
    39          * @param {string} options.params.primarySetting   The ID for the primary setting the partial renders.
    40          * @param {bool}   options.params.fallbackRefresh  Whether to refresh the entire preview in case of a partial refresh failure.
     33         * @param {string}       id                              Unique identifier for the control instance.
     34         * @param {object}       options                         Options hash for the control instance.
     35         * @param {object}       options.params
     36         * @param {string}       options.params.type             Type of partial (e.g. nav_menu, widget, etc)
     37         * @param {string}       options.params.selector         jQuery selector to find the container element in the page.
     38         * @param {object|array} options.params.settings         The IDs for the settings the partial relates to, either an array of IDs or an object mapping to setting values.
     39         * @param {bool}         options.params.fallbackRefresh  Whether to refresh the entire preview in case of a partial refresh failure.
    4140         */
    4241        Partial = self.Partial = api.Class.extend({
    4342
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    6059                        partial.params = _.extend(
    6160                                {
    6261                                        selector: null,
    63                                         settings: [],
     62                                        settings: {},
    6463                                        primarySetting: null,
    6564                                        containerInclusive: false,
    6665                                        fallbackRefresh: true // Note this needs to be false in a front-end editing context.
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    140139                 */
    141140                settings: function() {
    142141                        var partial = this;
    143                         if ( partial.params.settings && 0 !== partial.params.settings.length ) {
     142                        if ( _.isArray( partial.params.settings ) && 0 !== partial.params.settings.length ) {
    144143                                return partial.params.settings;
    145                         } else if ( partial.params.primarySetting ) {
    146                                 return [ partial.params.primarySetting ];
     144                        } else if ( _.isObject( partial.params.settings ) ) {
     145                                return _.values( partial.params.settings );
    147146                        } else {
    148147                                return [ partial.id ];
    149148                        }
    wp.customize.selectiveRefresh = ( function( $, api ) { 
    176175                 * @since 4.5.0
    177176                 */
    178177                showControl: function() {
    179                         var partial = this, settingId = partial.params.primarySetting;
    180                         if ( ! settingId ) {
     178                        var partial = this, settingId;
     179                        if ( partial.params.primarySetting ) {
     180                                settingId = partial.params.primarySetting;
     181                        } else if ( _.isObject( partial.params.settings ) && partial.params.settings['default'] ) {
     182                                settingId = partial.params.settings['default'];
     183                        } else {
    181184                                settingId = _.first( partial.settings() );
    182185                        }
    183186                        api.preview.send( 'focus-control-for-setting', settingId );