Customize: Fix persistence of toggles for displayed nav menu item properties.

* Eliminates need to click more than one checkbox to have preferences saved.
* Adds debouncing to saving user-selected menu item properties.
* Also removes discrepancies between available nav menu item properties on admin page vs Customizer.

Fixes #35273.
Props afercia, westonruter.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-03-09 21:41:28 +00:00
parent f39d1e4fcc
commit 7441acafaf
5 changed files with 36 additions and 39 deletions

View File

@ -937,17 +937,17 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
*
* @since 3.0.0
*
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
* @return array Columns.
*/
function wp_nav_menu_manage_columns() {
return array(
'_title' => __('Show advanced menu properties'),
'cb' => '<input type="checkbox" />',
'title-attribute' => __('Title Attribute'),
'link-target' => __('Link Target'),
'css-classes' => __('CSS Classes'),
'xfn' => __('Link Relationship (XFN)'),
'description' => __('Description'),
'_title' => __( 'Show advanced menu properties' ),
'cb' => '<input type="checkbox" />',
'link-target' => __( 'Link Target' ),
'attr-title' => __( 'Title Attribute' ),
'css-classes' => __( 'CSS Classes' ),
'xfn' => __( 'Link Relationship (XFN)' ),
'description' => __( 'Description' ),
);
}

View File

@ -218,7 +218,7 @@
.prop( 'tabIndex', -1 )
.removeClass( 'is-visible' );
}
this.searchTerm = event.target.value;
this.pages.search = 1;
this.doSearch( 1 );
@ -614,15 +614,21 @@
});
},
saveManageColumnsState: function() {
var hidden = this.hidden();
$.post( wp.ajax.settings.url, {
action: 'hidden-columns',
hidden: hidden,
saveManageColumnsState: _.debounce( function() {
var panel = this;
if ( panel._updateHiddenColumnsRequest ) {
panel._updateHiddenColumnsRequest.abort();
}
panel._updateHiddenColumnsRequest = wp.ajax.post( 'hidden-columns', {
hidden: panel.hidden(),
screenoptionnonce: $( '#screenoptionnonce' ).val(),
page: 'nav-menus'
});
},
} );
panel._updateHiddenColumnsRequest.always( function() {
panel._updateHiddenColumnsRequest = null;
} );
}, 2000 ),
checked: function( column ) {
this.container.addClass( 'field-' + column + '-active' );
@ -633,12 +639,10 @@
},
hidden: function() {
this.hidden = function() {
return $( '.hide-column-tog' ).not( ':checked' ).map( function() {
var id = this.id;
return id.substring( id, id.length - 5 );
}).get().join( ',' );
};
return $( '.hide-column-tog' ).not( ':checked' ).map( function() {
var id = this.id;
return id.substring( 0, id.length - 5 );
}).get().join( ',' );
}
} );

File diff suppressed because one or more lines are too long

View File

@ -34,8 +34,9 @@ class WP_Customize_Nav_Menus_Panel extends WP_Customize_Panel {
* @access public
*/
public function render_screen_options() {
// Essentially adds the screen options.
add_filter( 'manage_nav-menus_columns', array( $this, 'wp_nav_menu_manage_columns' ) );
// Adds the screen options.
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
// Display screen options.
$screen = WP_Screen::get( 'nav-menus.php' );
@ -48,20 +49,12 @@ class WP_Customize_Nav_Menus_Panel extends WP_Customize_Panel {
* Link title attribute added as it's a relatively advanced concept for new users.
*
* @since 4.3.0
* @access public
*
* @return array The advanced menu properties.
* @deprecated 4.5.0 Deprecated in favor of wp_nav_menu_manage_columns().
*/
public function wp_nav_menu_manage_columns() {
return array(
'_title' => __( 'Show advanced menu properties' ),
'cb' => '<input type="checkbox" />',
'link-target' => __( 'Link Target' ),
'attr-title' => __( 'Title Attribute' ),
'css-classes' => __( 'CSS Classes' ),
'xfn' => __( 'Link Relationship (XFN)' ),
'description' => __( 'Description' ),
);
_deprecated_function( __METHOD__, '4.5.0', 'wp_nav_menu_manage_columns' );
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
return wp_nav_menu_manage_columns();
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-beta2-36907';
$wp_version = '4.5-beta2-36908';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.