Mark menu items tied to invalid taxonomies and post types as invalid. props ocean90, see #13958.

git-svn-id: http://svn.automattic.com/wordpress/trunk@18260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-06-11 00:55:48 +00:00
parent 73c4a0929f
commit d648585363
5 changed files with 52 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -387,6 +387,16 @@ body {
-khtml-border-radius: 3px;
}
#menu-to-edit .menu-item-invalid .menu-item-handle {
background-color: #f6c9cc; /* Fallback */
background-image: -ms-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* Firefox */
background-image: -o-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#f6c9cc), to(#fdf8ff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* new Webkit */
background-image: linear-gradient(bottom, #f6c9cc, #fdf8ff); /* proposed W3C Markup */
}
.menu-item-edit-active .menu-item-handle {
-moz-border-radius: 3px 3px 0 0;
-webkit-border-bottom-right-radius: 0;

View File

@ -67,7 +67,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$title = $item->title;
if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
if ( ! empty( $item->_invalid ) ) {
$classes[] = 'menu-item-invalid';
/* translators: %s: title of menu item which is invalid */
$title = sprintf( __( '%s (Invalid)' ), $item->title );
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
$classes[] = 'pending';
/* translators: %s: title of menu item in draft status */
$title = sprintf( __('%s (Pending)'), $item->title );

View File

@ -442,6 +442,22 @@ function _sort_nav_menu_items( $a, $b ) {
return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
}
/**
* Returns if a menu item is valid. Bug #13958
*
* @since 3.2.0
* @access private
*
* @param object $menu_item The menu item to check
* @return bool false if invalid, else true.
*/
function _is_valid_nav_menu_item( $item ) {
if ( ! empty( $item->_invalid ) )
return false;
return true;
}
/**
* Returns all menu items of a navigation menu.
*
@ -512,6 +528,9 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
}
$items = array_map( 'wp_setup_nav_menu_item', $items );
if ( ! in_array( $args['post_status'], array( 'draft', 'any' ) ) )
$items = array_filter( $items, '_is_valid_nav_menu_item' );
if ( ARRAY_A == $args['output'] ) {
$GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
@ -560,7 +579,14 @@ function wp_setup_nav_menu_item( $menu_item ) {
if ( 'post_type' == $menu_item->type ) {
$object = get_post_type_object( $menu_item->object );
$menu_item->type_label = $object->labels->singular_name;
if ( $object ) {
$menu_item->type_label = $object->labels->singular_name;
} else {
$menu_item->type_label = $menu_item->object;
$menu_item->post_status = 'draft';
$menu_item->_invalid = true;
}
$menu_item->url = get_permalink( $menu_item->object_id );
$original_object = get_post( $menu_item->object_id );
@ -569,7 +595,14 @@ function wp_setup_nav_menu_item( $menu_item ) {
} elseif ( 'taxonomy' == $menu_item->type ) {
$object = get_taxonomy( $menu_item->object );
$menu_item->type_label = $object->labels->singular_name;
if ( $object ) {
$menu_item->type_label = $object->labels->singular_name;
} else {
$menu_item->type_label = $menu_item->object;
$menu_item->post_status = 'draft';
$menu_item->_invalid = true;
}
$term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';

View File

@ -512,7 +512,7 @@ function wp_default_styles( &$styles ) {
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u' );
$styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.css', array(), '0.9.8' );
$styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.1' );
$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20110514' );
$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20110610' );
$styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20110601' );
$styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' );
$styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' );