wp/wp-admin/includes/class-walker-nav-menu-checklist.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-admin/includes/class-walker-nav-menu-checklist.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/class-walker-nav-menu-checklist.php	Tue Dec 15 13:49:49 2020 +0100
@@ -30,11 +30,11 @@
 	 *
 	 * @since 3.0.0
 	 *
-	 * @param string $output Used to append additional content (passed by reference).
-	 * @param int    $depth  Depth of page. Used for padding.
-	 * @param array  $args   Not used.
+	 * @param string   $output Used to append additional content (passed by reference).
+	 * @param int      $depth  Depth of page. Used for padding.
+	 * @param stdClass $args   Not used.
 	 */
-	public function start_lvl( &$output, $depth = 0, $args = array() ) {
+	public function start_lvl( &$output, $depth = 0, $args = null ) {
 		$indent  = str_repeat( "\t", $depth );
 		$output .= "\n$indent<ul class='children'>\n";
 	}
@@ -46,11 +46,11 @@
 	 *
 	 * @since 3.0.0
 	 *
-	 * @param string $output Used to append additional content (passed by reference).
-	 * @param int    $depth  Depth of page. Used for padding.
-	 * @param array  $args   Not used.
+	 * @param string   $output Used to append additional content (passed by reference).
+	 * @param int      $depth  Depth of page. Used for padding.
+	 * @param stdClass $args   Not used.
 	 */
-	public function end_lvl( &$output, $depth = 0, $args = array() ) {
+	public function end_lvl( &$output, $depth = 0, $args = null ) {
 		$indent  = str_repeat( "\t", $depth );
 		$output .= "\n$indent</ul>";
 	}
@@ -62,26 +62,27 @@
 	 *
 	 * @since 3.0.0
 	 *
-	 * @global int $_nav_menu_placeholder
+	 * @global int        $_nav_menu_placeholder
+	 * @global int|string $nav_menu_selected_id
 	 *
-	 * @param string $output Used to append additional content (passed by reference).
-	 * @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.
+	 * @param string   $output Used to append additional content (passed by reference).
+	 * @param WP_Post  $item   Menu item data object.
+	 * @param int      $depth  Depth of menu item. Used for padding.
+	 * @param stdClass $args   Not used.
+	 * @param int      $id     Not used.
 	 */
-	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
-		global $_nav_menu_placeholder;
+	public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
+		global $_nav_menu_placeholder, $nav_menu_selected_id;
 
 		$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
-		$possible_object_id    = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
+		$possible_object_id    = isset( $item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder;
 		$possible_db_id        = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
 
 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
 
 		$output .= $indent . '<li>';
 		$output .= '<label class="menu-item-title">';
-		$output .= '<input type="checkbox" class="menu-item-checkbox';
+		$output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox';
 
 		if ( ! empty( $item->front_or_home ) ) {
 			$output .= ' add-to-top';
@@ -94,16 +95,18 @@
 		} elseif ( isset( $item->post_type ) ) {
 			/** This filter is documented in wp-includes/post-template.php */
 			$title = apply_filters( 'the_title', $item->post_title, $item->ID );
-			if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) {
-				/* translators: %s: front page title */
-				$title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title );
-			}
 		}
 
 		$output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
+
+		if ( empty( $item->label ) && isset( $item->post_type ) && 'page' === $item->post_type ) {
+			// Append post states.
+			$output .= _post_states( $item, false );
+		}
+
 		$output .= '</label>';
 
-		// Menu item hidden fields
+		// Menu item hidden fields.
 		$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
 		$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />';
 		$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $item->menu_item_parent ) . '" />';
@@ -111,9 +114,9 @@
 		$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $item->title ) . '" />';
 		$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $item->url ) . '" />';
 		$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $item->target ) . '" />';
-		$output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="' . esc_attr( $item->attr_title ) . '" />';
+		$output .= '<input type="hidden" class="menu-item-attr-title" name="menu-item[' . $possible_object_id . '][menu-item-attr-title]" value="' . esc_attr( $item->attr_title ) . '" />';
 		$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $item->classes ) ) . '" />';
 		$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />';
 	}
 
-} // Walker_Nav_Menu_Checklist
+}