- Timestamp:
- 09/08/2021 03:35:32 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-walker-nav-menu-edit.php
r51010 r51739 47 47 * @see Walker_Nav_Menu::start_el() 48 48 * @since 3.0.0 49 * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support. 49 50 * 50 51 * @global int $_wp_nav_menu_max_depth 51 52 * 52 * @param string $output Used to append additional content (passed by reference).53 * @param WP_Post $ itemMenu item data object.54 * @param int $depth Depth of menu item. Used for padding.55 * @param stdClass $args Not used.56 * @param int $id Not used.53 * @param string $output Used to append additional content (passed by reference). 54 * @param WP_Post $data_object Menu item data object. 55 * @param int $depth Depth of menu item. Used for padding. 56 * @param stdClass $args Not used. 57 * @param int $id Not used. 57 58 */ 58 public function start_el( &$output, $ item, $depth = 0, $args = null, $id = 0 ) {59 public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) { 59 60 global $_wp_nav_menu_max_depth; 61 62 // Restores the more descriptive, specific name for use within this method. 63 $menu_item = $data_object; 60 64 $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth; 61 65 62 66 ob_start(); 63 $item_id = esc_attr( $ item->ID );67 $item_id = esc_attr( $menu_item->ID ); 64 68 $removed_args = array( 65 69 'action', … … 73 77 $original_title = false; 74 78 75 if ( 'taxonomy' === $ item->type ) {76 $original_object = get_term( (int) $ item->object_id, $item->object );79 if ( 'taxonomy' === $menu_item->type ) { 80 $original_object = get_term( (int) $menu_item->object_id, $menu_item->object ); 77 81 if ( $original_object && ! is_wp_error( $original_object ) ) { 78 82 $original_title = $original_object->name; 79 83 } 80 } elseif ( 'post_type' === $ item->type ) {81 $original_object = get_post( $ item->object_id );84 } elseif ( 'post_type' === $menu_item->type ) { 85 $original_object = get_post( $menu_item->object_id ); 82 86 if ( $original_object ) { 83 87 $original_title = get_the_title( $original_object->ID ); 84 88 } 85 } elseif ( 'post_type_archive' === $ item->type ) {86 $original_object = get_post_type_object( $ item->object );89 } elseif ( 'post_type_archive' === $menu_item->type ) { 90 $original_object = get_post_type_object( $menu_item->object ); 87 91 if ( $original_object ) { 88 92 $original_title = $original_object->labels->archives; … … 92 96 $classes = array( 93 97 'menu-item menu-item-depth-' . $depth, 94 'menu-item-' . esc_attr( $ item->object ),98 'menu-item-' . esc_attr( $menu_item->object ), 95 99 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ), 96 100 ); 97 101 98 $title = $ item->title;99 100 if ( ! empty( $ item->_invalid ) ) {102 $title = $menu_item->title; 103 104 if ( ! empty( $menu_item->_invalid ) ) { 101 105 $classes[] = 'menu-item-invalid'; 102 106 /* translators: %s: Title of an invalid menu item. */ 103 $title = sprintf( __( '%s (Invalid)' ), $ item->title );104 } elseif ( isset( $ item->post_status ) && 'draft' === $item->post_status ) {107 $title = sprintf( __( '%s (Invalid)' ), $menu_item->title ); 108 } elseif ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { 105 109 $classes[] = 'pending'; 106 110 /* translators: %s: Title of a menu item in draft status. */ 107 $title = sprintf( __( '%s (Pending)' ), $ item->title );111 $title = sprintf( __( '%s (Pending)' ), $menu_item->title ); 108 112 } 109 113 110 $title = ( ! isset( $ item->label ) || '' === $item->label ) ? $title : $item->label;114 $title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label; 111 115 112 116 $submenu_text = ''; … … 125 129 </label> 126 130 <span class="item-controls"> 127 <span class="item-type"><?php echo esc_html( $ item->type_label ); ?></span>131 <span class="item-type"><?php echo esc_html( $menu_item->type_label ); ?></span> 128 132 <span class="item-order hide-if-js"> 129 133 <?php … … 186 190 187 191 <div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>"> 188 <?php if ( 'custom' === $ item->type ) : ?>192 <?php if ( 'custom' === $menu_item->type ) : ?> 189 193 <p class="field-url description description-wide"> 190 194 <label for="edit-menu-item-url-<?php echo $item_id; ?>"> 191 195 <?php _e( 'URL' ); ?><br /> 192 <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->url ); ?>" />196 <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->url ); ?>" /> 193 197 </label> 194 198 </p> … … 197 201 <label for="edit-menu-item-title-<?php echo $item_id; ?>"> 198 202 <?php _e( 'Navigation Label' ); ?><br /> 199 <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->title ); ?>" />203 <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->title ); ?>" /> 200 204 </label> 201 205 </p> … … 203 207 <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>"> 204 208 <?php _e( 'Title Attribute' ); ?><br /> 205 <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->post_excerpt ); ?>" />209 <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" /> 206 210 </label> 207 211 </p> 208 212 <p class="field-link-target description"> 209 213 <label for="edit-menu-item-target-<?php echo $item_id; ?>"> 210 <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $ item->target, '_blank' ); ?> />214 <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $menu_item->target, '_blank' ); ?> /> 211 215 <?php _e( 'Open link in a new tab' ); ?> 212 216 </label> … … 215 219 <label for="edit-menu-item-classes-<?php echo $item_id; ?>"> 216 220 <?php _e( 'CSS Classes (optional)' ); ?><br /> 217 <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $ item->classes ) ); ?>" />221 <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $menu_item->classes ) ); ?>" /> 218 222 </label> 219 223 </p> … … 221 225 <label for="edit-menu-item-xfn-<?php echo $item_id; ?>"> 222 226 <?php _e( 'Link Relationship (XFN)' ); ?><br /> 223 <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->xfn ); ?>" />227 <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->xfn ); ?>" /> 224 228 </label> 225 229 </p> … … 227 231 <label for="edit-menu-item-description-<?php echo $item_id; ?>"> 228 232 <?php _e( 'Description' ); ?><br /> 229 <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $ item->description ); // textarea_escaped ?></textarea>233 <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $menu_item->description ); // textarea_escaped ?></textarea> 230 234 <span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span> 231 235 </label> … … 238 242 * @since 5.4.0 239 243 * 240 * @param int $item_id Menu item ID.241 * @param WP_Post $ itemMenu item data object.242 * @param int $depth Depth of menu item. Used for padding.243 * @param stdClass $args An object of menu item arguments.244 * @param int $id Nav menu ID.244 * @param int $item_id Menu item ID. 245 * @param WP_Post $menu_item Menu item data object. 246 * @param int $depth Depth of menu item. Used for padding. 247 * @param stdClass $args An object of menu item arguments. 248 * @param int $id Nav menu ID. 245 249 */ 246 do_action( 'wp_nav_menu_item_custom_fields', $item_id, $ item, $depth, $args, $id );250 do_action( 'wp_nav_menu_item_custom_fields', $item_id, $menu_item, $depth, $args, $id ); 247 251 ?> 248 252 … … 257 261 258 262 <div class="menu-item-actions description-wide submitbox"> 259 <?php if ( 'custom' !== $ item->type && false !== $original_title ) : ?>263 <?php if ( 'custom' !== $menu_item->type && false !== $original_title ) : ?> 260 264 <p class="link-to-original"> 261 265 <?php 262 266 /* translators: %s: Link to menu item's original object. */ 263 printf( __( 'Original: %s' ), '<a href="' . esc_attr( $ item->url ) . '">' . esc_html( $original_title ) . '</a>' );267 printf( __( 'Original: %s' ), '<a href="' . esc_attr( $menu_item->url ) . '">' . esc_html( $original_title ) . '</a>' ); 264 268 ?> 265 269 </p> … … 304 308 305 309 <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" /> 306 <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->object_id ); ?>" />307 <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->object ); ?>" />308 <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->menu_item_parent ); ?>" />309 <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->menu_order ); ?>" />310 <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $ item->type ); ?>" />310 <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->object_id ); ?>" /> 311 <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->object ); ?>" /> 312 <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_item_parent ); ?>" /> 313 <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" /> 314 <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->type ); ?>" /> 311 315 </div><!-- .menu-item-settings--> 312 316 <ul class="menu-item-transport"></ul>
Note: See TracChangeset
for help on using the changeset viewer.