X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..fa11948979fd6a4ea5705dc613b239699a459db3:/wp-admin/includes/nav-menu.php diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 6e929286..d3aa7bd0 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -7,39 +7,49 @@ * @since 3.0.0 * @uses Walker_Nav_Menu */ -class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { +class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { /** + * Starts the list before the elements are added. + * * @see Walker_Nav_Menu::start_lvl() + * * @since 3.0.0 * * @param string $output Passed by reference. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. */ - function start_lvl(&$output) {} + function start_lvl( &$output, $depth = 0, $args = array() ) {} /** + * Ends the list of after the elements are added. + * * @see Walker_Nav_Menu::end_lvl() + * * @since 3.0.0 * * @param string $output Passed by reference. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. */ - function end_lvl(&$output) { - } + function end_lvl( &$output, $depth = 0, $args = array() ) {} /** - * @see Walker::start_el() + * Start the element output. + * + * @see Walker_Nav_Menu::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. - * @param object $item Menu item data object. - * @param int $depth Depth of menu item. Used for padding. - * @param object $args + * @param object $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @param array $args Not used. + * @param int $id Not used. */ - function start_el(&$output, $item, $depth, $args) { + function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $_wp_nav_menu_max_depth; $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; - $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; - ob_start(); $item_id = esc_attr( $item->ID ); $removed_args = array( @@ -54,9 +64,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $original_title = ''; if ( 'taxonomy' == $item->type ) { $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' ); + if ( is_wp_error( $original_title ) ) + $original_title = false; } elseif ( 'post_type' == $item->type ) { $original_object = get_post( $item->object_id ); - $original_title = $original_object->post_title; + $original_title = get_the_title( $original_object->ID ); } $classes = array( @@ -67,22 +79,30 @@ 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 ); } - $title = empty( $item->label ) ? $title : $item->label; + $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label; + + $submenu_text = ''; + if ( 0 == $depth ) + $submenu_text = 'style="display: none;"'; ?>