- 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-checklist.php
r49936 r51739 62 62 * 63 63 * @since 3.0.0 64 * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support. 64 65 * 65 66 * @global int $_nav_menu_placeholder 66 67 * @global int|string $nav_menu_selected_id 67 68 * 68 * @param string $output Used to append additional content (passed by reference).69 * @param WP_Post $ itemMenu item data object.70 * @param int $depth Depth of menu item. Used for padding.71 * @param stdClass $args Not used.72 * @param int $id Not used.69 * @param string $output Used to append additional content (passed by reference). 70 * @param WP_Post $data_object Menu item data object. 71 * @param int $depth Depth of menu item. Used for padding. 72 * @param stdClass $args Not used. 73 * @param int $id Not used. 73 74 */ 74 public function start_el( &$output, $ item, $depth = 0, $args = null, $id = 0 ) {75 public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) { 75 76 global $_nav_menu_placeholder, $nav_menu_selected_id; 76 77 78 // Restores the more descriptive, specific name for use within this method. 79 $menu_item = $data_object; 80 77 81 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; 78 $possible_object_id = isset( $ item->post_type ) && 'nav_menu_item' === $item->post_type ? $item->object_id : $_nav_menu_placeholder;79 $possible_db_id = ( ! empty( $ item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;82 $possible_object_id = isset( $menu_item->post_type ) && 'nav_menu_item' === $menu_item->post_type ? $menu_item->object_id : $_nav_menu_placeholder; 83 $possible_db_id = ( ! empty( $menu_item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $menu_item->ID : 0; 80 84 81 85 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; … … 85 89 $output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox'; 86 90 87 if ( ! empty( $ item->front_or_home ) ) {91 if ( ! empty( $menu_item->front_or_home ) ) { 88 92 $output .= ' add-to-top'; 89 93 } 90 94 91 $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $ item->object_id ) . '" /> ';95 $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $menu_item->object_id ) . '" /> '; 92 96 93 if ( ! empty( $ item->label ) ) {94 $title = $ item->label;95 } elseif ( isset( $ item->post_type ) ) {97 if ( ! empty( $menu_item->label ) ) { 98 $title = $menu_item->label; 99 } elseif ( isset( $menu_item->post_type ) ) { 96 100 /** This filter is documented in wp-includes/post-template.php */ 97 $title = apply_filters( 'the_title', $ item->post_title, $item->ID );101 $title = apply_filters( 'the_title', $menu_item->post_title, $menu_item->ID ); 98 102 } 99 103 100 $output .= isset( $title ) ? esc_html( $title ) : esc_html( $ item->title );104 $output .= isset( $title ) ? esc_html( $title ) : esc_html( $menu_item->title ); 101 105 102 if ( empty( $ item->label ) && isset( $item->post_type ) && 'page' === $item->post_type ) {106 if ( empty( $menu_item->label ) && isset( $menu_item->post_type ) && 'page' === $menu_item->post_type ) { 103 107 // Append post states. 104 $output .= _post_states( $ item, false );108 $output .= _post_states( $menu_item, false ); 105 109 } 106 110 … … 109 113 // Menu item hidden fields. 110 114 $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; 111 $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $ item->object ) . '" />';112 $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 ) . '" />';113 $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $ item->type ) . '" />';114 $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $ item->title ) . '" />';115 $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $ item->url ) . '" />';116 $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $ item->target ) . '" />';117 $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 ) . '" />';118 $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $ item->classes ) ) . '" />';119 $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $ item->xfn ) . '" />';115 $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $menu_item->object ) . '" />'; 116 $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $menu_item->menu_item_parent ) . '" />'; 117 $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $menu_item->type ) . '" />'; 118 $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $menu_item->title ) . '" />'; 119 $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $menu_item->url ) . '" />'; 120 $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $menu_item->target ) . '" />'; 121 $output .= '<input type="hidden" class="menu-item-attr-title" name="menu-item[' . $possible_object_id . '][menu-item-attr-title]" value="' . esc_attr( $menu_item->attr_title ) . '" />'; 122 $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $menu_item->classes ) ) . '" />'; 123 $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $menu_item->xfn ) . '" />'; 120 124 } 121 125
Note: See TracChangeset
for help on using the changeset viewer.