Improvements to invalid menu item handling. Props ocean90. fixes #13958
git-svn-id: http://svn.automattic.com/wordpress/trunk@18277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
46f63a6b1e
commit
4bb54d8f68
File diff suppressed because one or more lines are too long
|
@ -86,7 +86,7 @@ body {
|
||||||
border-top: 1px solid;
|
border-top: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#post-body div.updated {
|
#post-body div.updated, #post-body div.error {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1103,15 +1103,20 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
|
||||||
else
|
else
|
||||||
return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
|
return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
|
||||||
|
|
||||||
$some_pending_menu_items = false;
|
$some_pending_menu_items = $some_invalid_menu_items = false;
|
||||||
foreach( (array) $menu_items as $menu_item ) {
|
foreach( (array) $menu_items as $menu_item ) {
|
||||||
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
|
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
|
||||||
$some_pending_menu_items = true;
|
$some_pending_menu_items = true;
|
||||||
|
if ( ! empty( $menu_item->_invalid ) )
|
||||||
|
$some_invalid_menu_items = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $some_pending_menu_items )
|
if ( $some_pending_menu_items )
|
||||||
$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
|
$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
|
||||||
|
|
||||||
|
if ( $some_invalid_menu_items )
|
||||||
|
$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
|
||||||
|
|
||||||
$result .= '<ul class="menu" id="menu-to-edit"> ';
|
$result .= '<ul class="menu" id="menu-to-edit"> ';
|
||||||
$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
|
$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
|
||||||
$result .= ' </ul> ';
|
$result .= ' </ul> ';
|
||||||
|
|
|
@ -529,7 +529,7 @@ 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' ) ) )
|
if ( ! is_admin() ) // Remove invalid items only in frontend
|
||||||
$items = array_filter( $items, '_is_valid_nav_menu_item' );
|
$items = array_filter( $items, '_is_valid_nav_menu_item' );
|
||||||
|
|
||||||
if ( ARRAY_A == $args['output'] ) {
|
if ( ARRAY_A == $args['output'] ) {
|
||||||
|
@ -583,7 +583,6 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
||||||
$menu_item->type_label = $object->labels->singular_name;
|
$menu_item->type_label = $object->labels->singular_name;
|
||||||
} else {
|
} else {
|
||||||
$menu_item->type_label = $menu_item->object;
|
$menu_item->type_label = $menu_item->object;
|
||||||
$menu_item->post_status = 'draft';
|
|
||||||
$menu_item->_invalid = true;
|
$menu_item->_invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +598,6 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
||||||
$menu_item->type_label = $object->labels->singular_name;
|
$menu_item->type_label = $object->labels->singular_name;
|
||||||
} else {
|
} else {
|
||||||
$menu_item->type_label = $menu_item->object;
|
$menu_item->type_label = $menu_item->object;
|
||||||
$menu_item->post_status = 'draft';
|
|
||||||
$menu_item->_invalid = true;
|
$menu_item->_invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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(), '20110610' );
|
$styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20110611' );
|
||||||
$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