Customize: Fix visible edit shortcuts for `wp_nav_menu()` instances using the `menu` arg (such as in the Custom Menu widget) instead of the `theme_location` arg.
Also fix logic for `focus-control-for-setting` handler to focus on the first control (lowest `priority` value) associated with a given setting instead of the last control encountered when iterating over all controls, as this ensures the first control in a `nav_menu` section is focused rather than the last one. Props westonruter, sirbrillig. See #27403. Merges [39622] to the 4.7 branch. Fixes #39101. Built from https://develop.svn.wordpress.org/branches/4.7@39653 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8f7e4969bc
commit
fb52c9599d
|
@ -5365,16 +5365,20 @@
|
||||||
|
|
||||||
// Focus on the control that is associated with the given setting.
|
// Focus on the control that is associated with the given setting.
|
||||||
api.previewer.bind( 'focus-control-for-setting', function( settingId ) {
|
api.previewer.bind( 'focus-control-for-setting', function( settingId ) {
|
||||||
var matchedControl;
|
var matchedControls = [];
|
||||||
api.control.each( function( control ) {
|
api.control.each( function( control ) {
|
||||||
var settingIds = _.pluck( control.settings, 'id' );
|
var settingIds = _.pluck( control.settings, 'id' );
|
||||||
if ( -1 !== _.indexOf( settingIds, settingId ) ) {
|
if ( -1 !== _.indexOf( settingIds, settingId ) ) {
|
||||||
matchedControl = control;
|
matchedControls.push( control );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( matchedControl ) {
|
// Focus on the matched control with the lowest priority (appearing higher).
|
||||||
matchedControl.focus();
|
if ( matchedControls.length ) {
|
||||||
|
matchedControls.sort( function( a, b ) {
|
||||||
|
return a.priority() - b.priority();
|
||||||
|
} );
|
||||||
|
matchedControls[0].focus();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -312,14 +312,15 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
|
||||||
* @since 4.5.0
|
* @since 4.5.0
|
||||||
*/
|
*/
|
||||||
showControl: function() {
|
showControl: function() {
|
||||||
var partial = this, settingId = partial.params.primarySetting, menuSlug;
|
var partial = this, settingId = partial.params.primarySetting;
|
||||||
if ( ! settingId ) {
|
if ( ! settingId ) {
|
||||||
settingId = _.first( partial.settings() );
|
settingId = _.first( partial.settings() );
|
||||||
}
|
}
|
||||||
if ( partial.getType() === 'nav_menu' ) {
|
if ( partial.getType() === 'nav_menu' ) {
|
||||||
menuSlug = partial.params.navMenuArgs.theme_location;
|
if ( partial.params.navMenuArgs.theme_location ) {
|
||||||
if ( menuSlug ) {
|
settingId = 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']';
|
||||||
settingId = 'nav_menu_locations[' + menuSlug + ']';
|
} else if ( partial.params.navMenuArgs.menu ) {
|
||||||
|
settingId = 'nav_menu[' + String( partial.params.navMenuArgs.menu ) + ']';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
api.preview.send( 'focus-control-for-setting', settingId );
|
api.preview.send( 'focus-control-for-setting', settingId );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7.1-alpha-39652';
|
$wp_version = '4.7.1-alpha-39653';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue