Customizer: Implement indicators for invalid nav menu items.
The same indicator on the nav menus admin page is now present for nav menu items in the Customizer. When a menu item is present for a post type that is no longer registered, the menu item will appear with the indicator. Props kucrut, westonruter. Fixes #33665. Built from https://develop.svn.wordpress.org/trunk@35302 git-svn-id: http://core.svn.wordpress.org/trunk@35268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0715dc8a4f
commit
6d9d18315d
|
@ -1250,16 +1250,21 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var titleEl = control.container.find( '.menu-item-title' );
|
||||
var titleEl = control.container.find( '.menu-item-title' ),
|
||||
titleText = item.title || api.Menus.data.l10n.untitled;
|
||||
|
||||
if ( item._invalid ) {
|
||||
titleText = api.Menus.data.l10n.invalidTitleTpl.replace( '%s', titleText );
|
||||
}
|
||||
|
||||
// Don't update to an empty title.
|
||||
if ( item.title ) {
|
||||
titleEl
|
||||
.text( item.title )
|
||||
.text( titleText )
|
||||
.removeClass( 'no-title' );
|
||||
} else {
|
||||
titleEl
|
||||
.text( api.Menus.data.l10n.untitled )
|
||||
.text( titleText )
|
||||
.addClass( 'no-title' );
|
||||
}
|
||||
} );
|
||||
|
@ -1303,9 +1308,9 @@
|
|||
'menu-item-edit-inactive'
|
||||
];
|
||||
|
||||
if ( settingValue.invalid ) {
|
||||
containerClasses.push( 'invalid' );
|
||||
control.params.title = api.Menus.data.invalidTitleTpl.replace( '%s', control.params.title );
|
||||
if ( settingValue._invalid ) {
|
||||
containerClasses.push( 'menu-item-invalid' );
|
||||
control.params.title = api.Menus.data.l10n.invalidTitleTpl.replace( '%s', control.params.title );
|
||||
} else if ( 'draft' === settingValue.status ) {
|
||||
containerClasses.push( 'pending' );
|
||||
control.params.title = api.Menus.data.pendingTitleTpl.replace( '%s', control.params.title );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -885,7 +885,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
'status' => 'publish',
|
||||
'original_title' => '',
|
||||
'nav_menu_term_id' => 0, // This will be supplied as the $menu_id arg for wp_update_nav_menu_item().
|
||||
// @todo also expose invalid?
|
||||
'_invalid' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -1144,6 +1144,14 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! isset( $this->value['_invalid'] ) ) {
|
||||
$this->value['_invalid'] = (
|
||||
( 'post_type' === $this->value['type'] && ! post_type_exists( $this->value['object'] ) )
|
||||
||
|
||||
( 'taxonomy' === $this->value['type'] && ! taxonomy_exists( $this->value['object'] ) )
|
||||
);
|
||||
}
|
||||
|
||||
// Remove remaining properties available on a setup nav_menu_item post object which aren't relevant to the setting value.
|
||||
$irrelevant_properties = array(
|
||||
'ID',
|
||||
|
@ -1246,6 +1254,8 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
$should_remove = (
|
||||
false === $this_item
|
||||
||
|
||||
true === $this_item['_invalid']
|
||||
||
|
||||
(
|
||||
$this->original_nav_menu_term_id === $menu->term_id
|
||||
&&
|
||||
|
@ -1417,6 +1427,7 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
'status' => 'publish',
|
||||
'original_title' => '',
|
||||
'nav_menu_term_id' => 0,
|
||||
'_invalid' => false,
|
||||
);
|
||||
$menu_item_value = array_merge( $default, $menu_item_value );
|
||||
$menu_item_value = wp_array_slice_assoc( $menu_item_value, array_keys( $default ) );
|
||||
|
@ -1449,6 +1460,8 @@ class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting {
|
|||
$menu_item_value['status'] = 'publish';
|
||||
}
|
||||
|
||||
$menu_item_value['_invalid'] = (bool) $menu_item_value['_invalid'];
|
||||
|
||||
/** This filter is documented in wp-includes/class-wp-customize-setting.php */
|
||||
return apply_filters( "customize_sanitize_{$this->id}", $menu_item_value, $this );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-35301';
|
||||
$wp_version = '4.4-alpha-35302';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue