Mark menu items tied to invalid taxonomies and post types as invalid. props ocean90, see #13958.
git-svn-id: https://develop.svn.wordpress.org/trunk@18260 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
64b6104534
commit
c24e4daf5a
File diff suppressed because one or more lines are too long
@ -387,6 +387,16 @@ body {
|
|||||||
-khtml-border-radius: 3px;
|
-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 {
|
.menu-item-edit-active .menu-item-handle {
|
||||||
-moz-border-radius: 3px 3px 0 0;
|
-moz-border-radius: 3px 3px 0 0;
|
||||||
-webkit-border-bottom-right-radius: 0;
|
-webkit-border-bottom-right-radius: 0;
|
||||||
|
@ -67,7 +67,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||||||
|
|
||||||
$title = $item->title;
|
$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';
|
$classes[] = 'pending';
|
||||||
/* translators: %s: title of menu item in draft status */
|
/* translators: %s: title of menu item in draft status */
|
||||||
$title = sprintf( __('%s (Pending)'), $item->title );
|
$title = sprintf( __('%s (Pending)'), $item->title );
|
||||||
|
@ -442,6 +442,22 @@ function _sort_nav_menu_items( $a, $b ) {
|
|||||||
return strcmp( $a->$_menu_item_sort_prop, $b->$_menu_item_sort_prop );
|
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.
|
* Returns all menu items of a navigation menu.
|
||||||
*
|
*
|
||||||
@ -513,6 +529,9 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
|
|||||||
|
|
||||||
$items = array_map( 'wp_setup_nav_menu_item', $items );
|
$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'] ) {
|
if ( ARRAY_A == $args['output'] ) {
|
||||||
$GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
|
$GLOBALS['_menu_item_sort_prop'] = $args['output_key'];
|
||||||
usort($items, '_sort_nav_menu_items');
|
usort($items, '_sort_nav_menu_items');
|
||||||
@ -560,7 +579,14 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
|||||||
|
|
||||||
if ( 'post_type' == $menu_item->type ) {
|
if ( 'post_type' == $menu_item->type ) {
|
||||||
$object = get_post_type_object( $menu_item->object );
|
$object = get_post_type_object( $menu_item->object );
|
||||||
|
if ( $object ) {
|
||||||
$menu_item->type_label = $object->labels->singular_name;
|
$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 );
|
$menu_item->url = get_permalink( $menu_item->object_id );
|
||||||
|
|
||||||
$original_object = get_post( $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 ) {
|
} elseif ( 'taxonomy' == $menu_item->type ) {
|
||||||
$object = get_taxonomy( $menu_item->object );
|
$object = get_taxonomy( $menu_item->object );
|
||||||
|
if ( $object ) {
|
||||||
$menu_item->type_label = $object->labels->singular_name;
|
$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 );
|
$term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
|
||||||
$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
|
$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ function wp_default_styles( &$styles ) {
|
|||||||
$styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u' );
|
$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( '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( '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( '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( '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' );
|
$styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' );
|
||||||
|
Loading…
Reference in New Issue
Block a user