Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::start_el()`.
In the parent class, renames the parameter `$object` to `$data_object`. Why? `object` is a PHP reserved keyword. In each child class: renames the corresponding parameter to match the parent's method signature. Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match. Changes for readability: - `@since` clearly specifies the original parameter name and its new name as well as why the change happened. - in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made. - in cases where the original parameter name was too generic, renamed (when reassigning) to a more descriptive name for use within the method. Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189]. Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion. See #51553. Built from https://develop.svn.wordpress.org/trunk@51739 git-svn-id: http://core.svn.wordpress.org/trunk@51347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
25da00ea81
commit
1105ddf965
|
@ -61,14 +61,18 @@ class Walker_Category_Checklist extends Walker {
|
|||
* @see Walker::start_el()
|
||||
*
|
||||
* @since 2.5.1
|
||||
* @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Term $category The current term object.
|
||||
* @param WP_Term $data_object The current term object.
|
||||
* @param int $depth Depth of the term in reference to parents. Default 0.
|
||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
* @param int $id ID of the current term.
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$category = $data_object;
|
||||
|
||||
if ( empty( $args['taxonomy'] ) ) {
|
||||
$taxonomy = 'category';
|
||||
} else {
|
||||
|
|
|
@ -61,22 +61,26 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
* @see Walker_Nav_Menu::start_el()
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @global int $_nav_menu_placeholder
|
||||
* @global int|string $nav_menu_selected_id
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $data_object 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 = null, $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) {
|
||||
global $_nav_menu_placeholder, $nav_menu_selected_id;
|
||||
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$menu_item = $data_object;
|
||||
|
||||
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_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_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
|
||||
$possible_object_id = isset( $menu_item->post_type ) && 'nav_menu_item' === $menu_item->post_type ? $menu_item->object_id : $_nav_menu_placeholder;
|
||||
$possible_db_id = ( ! empty( $menu_item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $menu_item->ID : 0;
|
||||
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
|
@ -84,39 +88,39 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
$output .= '<label class="menu-item-title">';
|
||||
$output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox';
|
||||
|
||||
if ( ! empty( $item->front_or_home ) ) {
|
||||
if ( ! empty( $menu_item->front_or_home ) ) {
|
||||
$output .= ' add-to-top';
|
||||
}
|
||||
|
||||
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $item->object_id ) . '" /> ';
|
||||
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $menu_item->object_id ) . '" /> ';
|
||||
|
||||
if ( ! empty( $item->label ) ) {
|
||||
$title = $item->label;
|
||||
} elseif ( isset( $item->post_type ) ) {
|
||||
if ( ! empty( $menu_item->label ) ) {
|
||||
$title = $menu_item->label;
|
||||
} elseif ( isset( $menu_item->post_type ) ) {
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$title = apply_filters( 'the_title', $item->post_title, $item->ID );
|
||||
$title = apply_filters( 'the_title', $menu_item->post_title, $menu_item->ID );
|
||||
}
|
||||
|
||||
$output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
|
||||
$output .= isset( $title ) ? esc_html( $title ) : esc_html( $menu_item->title );
|
||||
|
||||
if ( empty( $item->label ) && isset( $item->post_type ) && 'page' === $item->post_type ) {
|
||||
if ( empty( $menu_item->label ) && isset( $menu_item->post_type ) && 'page' === $menu_item->post_type ) {
|
||||
// Append post states.
|
||||
$output .= _post_states( $item, false );
|
||||
$output .= _post_states( $menu_item, false );
|
||||
}
|
||||
|
||||
$output .= '</label>';
|
||||
|
||||
// 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 ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $item->type ) . '" />';
|
||||
$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-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 ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $menu_item->object ) . '" />';
|
||||
$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 ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $menu_item->type ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $menu_item->title ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $menu_item->url ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $menu_item->target ) . '" />';
|
||||
$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 ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $menu_item->classes ) ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $menu_item->xfn ) . '" />';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,21 +46,25 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
*
|
||||
* @see Walker_Nav_Menu::start_el()
|
||||
* @since 3.0.0
|
||||
* @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @global int $_wp_nav_menu_max_depth
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $data_object 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 = null, $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) {
|
||||
global $_wp_nav_menu_max_depth;
|
||||
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$menu_item = $data_object;
|
||||
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
|
||||
|
||||
ob_start();
|
||||
$item_id = esc_attr( $item->ID );
|
||||
$item_id = esc_attr( $menu_item->ID );
|
||||
$removed_args = array(
|
||||
'action',
|
||||
'customlink-tab',
|
||||
|
@ -72,18 +76,18 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
|
||||
$original_title = false;
|
||||
|
||||
if ( 'taxonomy' === $item->type ) {
|
||||
$original_object = get_term( (int) $item->object_id, $item->object );
|
||||
if ( 'taxonomy' === $menu_item->type ) {
|
||||
$original_object = get_term( (int) $menu_item->object_id, $menu_item->object );
|
||||
if ( $original_object && ! is_wp_error( $original_object ) ) {
|
||||
$original_title = $original_object->name;
|
||||
}
|
||||
} elseif ( 'post_type' === $item->type ) {
|
||||
$original_object = get_post( $item->object_id );
|
||||
} elseif ( 'post_type' === $menu_item->type ) {
|
||||
$original_object = get_post( $menu_item->object_id );
|
||||
if ( $original_object ) {
|
||||
$original_title = get_the_title( $original_object->ID );
|
||||
}
|
||||
} elseif ( 'post_type_archive' === $item->type ) {
|
||||
$original_object = get_post_type_object( $item->object );
|
||||
} elseif ( 'post_type_archive' === $menu_item->type ) {
|
||||
$original_object = get_post_type_object( $menu_item->object );
|
||||
if ( $original_object ) {
|
||||
$original_title = $original_object->labels->archives;
|
||||
}
|
||||
|
@ -91,23 +95,23 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
|
||||
$classes = array(
|
||||
'menu-item menu-item-depth-' . $depth,
|
||||
'menu-item-' . esc_attr( $item->object ),
|
||||
'menu-item-' . esc_attr( $menu_item->object ),
|
||||
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
|
||||
);
|
||||
|
||||
$title = $item->title;
|
||||
$title = $menu_item->title;
|
||||
|
||||
if ( ! empty( $item->_invalid ) ) {
|
||||
if ( ! empty( $menu_item->_invalid ) ) {
|
||||
$classes[] = 'menu-item-invalid';
|
||||
/* translators: %s: Title of an invalid menu item. */
|
||||
$title = sprintf( __( '%s (Invalid)' ), $item->title );
|
||||
} elseif ( isset( $item->post_status ) && 'draft' === $item->post_status ) {
|
||||
$title = sprintf( __( '%s (Invalid)' ), $menu_item->title );
|
||||
} elseif ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) {
|
||||
$classes[] = 'pending';
|
||||
/* translators: %s: Title of a menu item in draft status. */
|
||||
$title = sprintf( __( '%s (Pending)' ), $item->title );
|
||||
$title = sprintf( __( '%s (Pending)' ), $menu_item->title );
|
||||
}
|
||||
|
||||
$title = ( ! isset( $item->label ) || '' === $item->label ) ? $title : $item->label;
|
||||
$title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label;
|
||||
|
||||
$submenu_text = '';
|
||||
if ( 0 === $depth ) {
|
||||
|
@ -124,7 +128,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span>
|
||||
</label>
|
||||
<span class="item-controls">
|
||||
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
|
||||
<span class="item-type"><?php echo esc_html( $menu_item->type_label ); ?></span>
|
||||
<span class="item-order hide-if-js">
|
||||
<?php
|
||||
printf(
|
||||
|
@ -185,48 +189,48 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
</div>
|
||||
|
||||
<div class="menu-item-settings wp-clearfix" id="menu-item-settings-<?php echo $item_id; ?>">
|
||||
<?php if ( 'custom' === $item->type ) : ?>
|
||||
<?php if ( 'custom' === $menu_item->type ) : ?>
|
||||
<p class="field-url description description-wide">
|
||||
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
|
||||
<?php _e( 'URL' ); ?><br />
|
||||
<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 ); ?>" />
|
||||
<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 ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<p class="description description-wide">
|
||||
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
|
||||
<?php _e( 'Navigation Label' ); ?><br />
|
||||
<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 ); ?>" />
|
||||
<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 ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-title-attribute field-attr-title description description-wide">
|
||||
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
|
||||
<?php _e( 'Title Attribute' ); ?><br />
|
||||
<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 ); ?>" />
|
||||
<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 ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-link-target description">
|
||||
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
|
||||
<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' ); ?> />
|
||||
<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' ); ?> />
|
||||
<?php _e( 'Open link in a new tab' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-css-classes description description-thin">
|
||||
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
|
||||
<?php _e( 'CSS Classes (optional)' ); ?><br />
|
||||
<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 ) ); ?>" />
|
||||
<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 ) ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-xfn description description-thin">
|
||||
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
|
||||
<?php _e( 'Link Relationship (XFN)' ); ?><br />
|
||||
<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 ); ?>" />
|
||||
<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 ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-description description description-wide">
|
||||
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
|
||||
<?php _e( 'Description' ); ?><br />
|
||||
<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>
|
||||
<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>
|
||||
<span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
|
||||
</label>
|
||||
</p>
|
||||
|
@ -238,12 +242,12 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
* @since 5.4.0
|
||||
*
|
||||
* @param int $item_id Menu item ID.
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $menu_item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param stdClass $args An object of menu item arguments.
|
||||
* @param int $id Nav menu ID.
|
||||
*/
|
||||
do_action( 'wp_nav_menu_item_custom_fields', $item_id, $item, $depth, $args, $id );
|
||||
do_action( 'wp_nav_menu_item_custom_fields', $item_id, $menu_item, $depth, $args, $id );
|
||||
?>
|
||||
|
||||
<fieldset class="field-move hide-if-no-js description description-wide">
|
||||
|
@ -256,11 +260,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
</fieldset>
|
||||
|
||||
<div class="menu-item-actions description-wide submitbox">
|
||||
<?php if ( 'custom' !== $item->type && false !== $original_title ) : ?>
|
||||
<?php if ( 'custom' !== $menu_item->type && false !== $original_title ) : ?>
|
||||
<p class="link-to-original">
|
||||
<?php
|
||||
/* translators: %s: Link to menu item's original object. */
|
||||
printf( __( 'Original: %s' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' );
|
||||
printf( __( 'Original: %s' ), '<a href="' . esc_attr( $menu_item->url ) . '">' . esc_html( $original_title ) . '</a>' );
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
@ -303,11 +307,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
</div>
|
||||
|
||||
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
|
||||
<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 ); ?>" />
|
||||
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
|
||||
<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 ); ?>" />
|
||||
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
|
||||
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
|
||||
<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 ); ?>" />
|
||||
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->object ); ?>" />
|
||||
<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 ); ?>" />
|
||||
<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 ); ?>" />
|
||||
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $menu_item->type ); ?>" />
|
||||
</div><!-- .menu-item-settings-->
|
||||
<ul class="menu-item-transport"></ul>
|
||||
<?php
|
||||
|
|
|
@ -20,16 +20,19 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Page' ) ) {
|
|||
* Outputs the beginning of the current element in the tree.
|
||||
*
|
||||
* @since Twenty Twenty 1.0
|
||||
* @since Twenty Twenty 1.9 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Used to append additional content. Passed by reference.
|
||||
* @param WP_Post $page Page data object.
|
||||
* @param WP_Post $data_object Page data object.
|
||||
* @param int $depth Optional. Depth of page. Used for padding. Default 0.
|
||||
* @param array $args Optional. Array of arguments. Default empty array.
|
||||
* @param int $current_page Optional. Page ID. Default 0.
|
||||
*/
|
||||
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_page = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$page = $data_object;
|
||||
|
||||
if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
|
||||
$t = "\t";
|
||||
|
|
|
@ -44,17 +44,20 @@ class Walker_CategoryDropdown extends Walker {
|
|||
* Starts the element output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Term $category Category data object.
|
||||
* @param WP_Term $data_object Category data object.
|
||||
* @param int $depth Depth of category. Used for padding.
|
||||
* @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
|
||||
* See wp_dropdown_categories().
|
||||
* @param int $id Optional. ID of the current category. Default 0 (unused).
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$category = $data_object;
|
||||
$pad = str_repeat( ' ', $depth * 3 );
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
|
|
|
@ -86,16 +86,21 @@ class Walker_Category extends Walker {
|
|||
* Starts the element output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Term $category Category data object.
|
||||
* @param WP_Term $data_object Category data object.
|
||||
* @param int $depth Optional. Depth of category in reference to parents. Default 0.
|
||||
* @param array $args Optional. An array of arguments. See wp_list_categories(). Default empty array.
|
||||
* @param array $args Optional. An array of arguments. See wp_list_categories().
|
||||
* Default empty array.
|
||||
* @param int $id Optional. ID of the current category. Default 0.
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$category = $data_object;
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$cat_name = apply_filters( 'list_cats', esc_attr( $category->name ), $category );
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ class Walker_Comment extends Walker {
|
|||
* Starts the element output.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @see wp_list_comments()
|
||||
|
@ -164,12 +165,15 @@ class Walker_Comment extends Walker {
|
|||
* @global WP_Comment $comment Global comment object.
|
||||
*
|
||||
* @param string $output Used to append additional content. Passed by reference.
|
||||
* @param WP_Comment $comment Comment data object.
|
||||
* @param WP_Comment $data_object Comment data object.
|
||||
* @param int $depth Optional. Depth of the current comment in reference to parents. Default 0.
|
||||
* @param array $args Optional. An array of arguments. Default empty array.
|
||||
* @param int $id Optional. ID of the current comment. Default 0 (unused).
|
||||
*/
|
||||
public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$comment = $data_object;
|
||||
|
||||
$depth++;
|
||||
$GLOBALS['comment_depth'] = $depth;
|
||||
$GLOBALS['comment'] = $comment;
|
||||
|
|
|
@ -106,16 +106,20 @@ class Walker_Nav_Menu extends Walker {
|
|||
*
|
||||
* @since 3.0.0
|
||||
* @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
|
||||
* @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $data_object Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param int $id Current item ID.
|
||||
*/
|
||||
public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$menu_item = $data_object;
|
||||
|
||||
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
|
||||
$t = '';
|
||||
$n = '';
|
||||
|
@ -125,8 +129,8 @@ class Walker_Nav_Menu extends Walker {
|
|||
}
|
||||
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
|
||||
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
$classes[] = 'menu-item-' . $item->ID;
|
||||
$classes = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes;
|
||||
$classes[] = 'menu-item-' . $menu_item->ID;
|
||||
|
||||
/**
|
||||
* Filters the arguments for a single nav menu item.
|
||||
|
@ -134,10 +138,10 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @since 4.4.0
|
||||
*
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $menu_item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
|
||||
$args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth );
|
||||
|
||||
/**
|
||||
* Filters the CSS classes applied to a menu item's list item element.
|
||||
|
@ -146,11 +150,11 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @since 4.1.0 The `$depth` parameter was added.
|
||||
*
|
||||
* @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
|
||||
* @param WP_Post $item The current menu item.
|
||||
* @param WP_Post $menu_item The current menu item object.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
|
||||
$class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
|
||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||
|
||||
/**
|
||||
|
@ -160,25 +164,25 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @since 4.1.0 The `$depth` parameter was added.
|
||||
*
|
||||
* @param string $menu_id The ID that is applied to the menu item's `<li>` element.
|
||||
* @param WP_Post $item The current menu item.
|
||||
* @param WP_Post $menu_item The current menu item.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
|
||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth );
|
||||
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||
|
||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||
|
||||
$atts = array();
|
||||
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
|
||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||
if ( '_blank' === $item->target && empty( $item->xfn ) ) {
|
||||
$atts['title'] = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : '';
|
||||
$atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
|
||||
if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) {
|
||||
$atts['rel'] = 'noopener';
|
||||
} else {
|
||||
$atts['rel'] = $item->xfn;
|
||||
$atts['rel'] = $menu_item->xfn;
|
||||
}
|
||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||
$atts['aria-current'] = $item->current ? 'page' : '';
|
||||
$atts['href'] = ! empty( $menu_item->url ) ? $menu_item->url : '';
|
||||
$atts['aria-current'] = $menu_item->current ? 'page' : '';
|
||||
|
||||
/**
|
||||
* Filters the HTML attributes applied to a menu item's anchor element.
|
||||
|
@ -195,11 +199,11 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @type string $href The href attribute.
|
||||
* @type string $aria-current The aria-current attribute.
|
||||
* }
|
||||
* @param WP_Post $item The current menu item.
|
||||
* @param WP_Post $menu_item The current menu item object.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
|
||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
|
||||
|
||||
$attributes = '';
|
||||
foreach ( $atts as $attr => $value ) {
|
||||
|
@ -210,7 +214,7 @@ class Walker_Nav_Menu extends Walker {
|
|||
}
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$title = apply_filters( 'the_title', $item->title, $item->ID );
|
||||
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
|
||||
|
||||
/**
|
||||
* Filters a menu item's title.
|
||||
|
@ -218,11 +222,11 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @since 4.4.0
|
||||
*
|
||||
* @param string $title The menu item's title.
|
||||
* @param WP_Post $item The current menu item.
|
||||
* @param WP_Post $menu_item The current menu item object.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
*/
|
||||
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
|
||||
$title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
|
||||
|
||||
$item_output = $args->before;
|
||||
$item_output .= '<a' . $attributes . '>';
|
||||
|
@ -240,11 +244,11 @@ class Walker_Nav_Menu extends Walker {
|
|||
* @since 3.0.0
|
||||
*
|
||||
* @param string $item_output The menu item's starting HTML output.
|
||||
* @param WP_Post $item Menu item data object.
|
||||
* @param WP_Post $menu_item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
*/
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,11 +44,12 @@ class Walker_PageDropdown extends Walker {
|
|||
* Starts the element output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Used to append additional content. Passed by reference.
|
||||
* @param WP_Post $page Page data object.
|
||||
* @param WP_Post $data_object Page data object.
|
||||
* @param int $depth Optional. Depth of page in reference to parent pages. Used for padding.
|
||||
* Default 0.
|
||||
* @param array $args Optional. Uses 'selected' argument for selected page to set selected HTML
|
||||
|
@ -56,7 +57,9 @@ class Walker_PageDropdown extends Walker {
|
|||
* attribute. See wp_dropdown_pages(). Default empty array.
|
||||
* @param int $id Optional. ID of the current page. Default 0 (unused).
|
||||
*/
|
||||
public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$page = $data_object;
|
||||
$pad = str_repeat( ' ', $depth * 3 );
|
||||
|
||||
if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
|
||||
|
|
|
@ -93,14 +93,18 @@ class Walker_Page extends Walker {
|
|||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.1.0
|
||||
* @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||
*
|
||||
* @param string $output Used to append additional content. Passed by reference.
|
||||
* @param WP_Post $page Page data object.
|
||||
* @param WP_Post $data_object Page data object.
|
||||
* @param int $depth Optional. Depth of page. Used for padding. Default 0.
|
||||
* @param array $args Optional. Array of arguments. Default empty array.
|
||||
* @param int $current_page Optional. Page ID. Default 0.
|
||||
*/
|
||||
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_page = 0 ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$page = $data_object;
|
||||
|
||||
if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
|
||||
$t = "\t";
|
||||
$n = "\n";
|
||||
|
|
|
@ -83,15 +83,16 @@ class Walker {
|
|||
* class methods. Includes the element output also.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.
|
||||
* @abstract
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param object $object The data object.
|
||||
* @param object $data_object The data object.
|
||||
* @param int $depth Depth of the item.
|
||||
* @param array $args An array of additional arguments.
|
||||
* @param int $current_object_id ID of the current item.
|
||||
*/
|
||||
public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
|
||||
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
|
||||
|
||||
/**
|
||||
* Ends the element output, if needed.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-51738';
|
||||
$wp_version = '5.9-alpha-51739';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue