Make WordPress Core

Changeset 51739


Ignore:
Timestamp:
09/08/2021 03:35:32 PM (2 years ago)
Author:
hellofromTonya
Message:

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.

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-walker-category-checklist.php

    r49197 r51739  
    6262     *
    6363     * @since 2.5.1
     64     * @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
    6465     *
    65      * @param string  $output   Used to append additional content (passed by reference).
    66      * @param WP_Term $category The current term object.
    67      * @param int     $depth    Depth of the term in reference to parents. Default 0.
    68      * @param array   $args     An array of arguments. @see wp_terms_checklist()
    69      * @param int     $id       ID of the current term.
     66     * @param string  $output      Used to append additional content (passed by reference).
     67     * @param WP_Term $data_object The current term object.
     68     * @param int     $depth       Depth of the term in reference to parents. Default 0.
     69     * @param array   $args        An array of arguments. @see wp_terms_checklist()
     70     * @param int     $id          ID of the current term.
    7071     */
    71     public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
     72    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
     73        // Restores the more descriptive, specific name for use within this method.
     74        $category = $data_object;
     75
    7276        if ( empty( $args['taxonomy'] ) ) {
    7377            $taxonomy = 'category';
  • trunk/src/wp-admin/includes/class-walker-nav-menu-checklist.php

    r49936 r51739  
    6262     *
    6363     * @since 3.0.0
     64     * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
    6465     *
    6566     * @global int        $_nav_menu_placeholder
    6667     * @global int|string $nav_menu_selected_id
    6768     *
    68      * @param string   $output Used to append additional content (passed by reference).
    69      * @param WP_Post  $item  Menu 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.
    7374     */
    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 ) {
    7576        global $_nav_menu_placeholder, $nav_menu_selected_id;
    7677
     78        // Restores the more descriptive, specific name for use within this method.
     79        $menu_item = $data_object;
     80
    7781        $_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;
    8084
    8185        $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
     
    8589        $output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox';
    8690
    87         if ( ! empty( $item->front_or_home ) ) {
     91        if ( ! empty( $menu_item->front_or_home ) ) {
    8892            $output .= ' add-to-top';
    8993        }
    9094
    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 ) . '" /> ';
    9296
    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 ) ) {
    96100            /** 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 );
    98102        }
    99103
    100         $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
     104        $output .= isset( $title ) ? esc_html( $title ) : esc_html( $menu_item->title );
    101105
    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 ) {
    103107            // Append post states.
    104             $output .= _post_states( $item, false );
     108            $output .= _post_states( $menu_item, false );
    105109        }
    106110
     
    109113        // Menu item hidden fields.
    110114        $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 ) . '" />';
    120124    }
    121125
  • trunk/src/wp-admin/includes/class-walker-nav-menu-edit.php

    r51010 r51739  
    4747     * @see Walker_Nav_Menu::start_el()
    4848     * @since 3.0.0
     49     * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
    4950     *
    5051     * @global int $_wp_nav_menu_max_depth
    5152     *
    52      * @param string   $output Used to append additional content (passed by reference).
    53      * @param WP_Post  $item  Menu 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.
    5758     */
    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 ) {
    5960        global $_wp_nav_menu_max_depth;
     61
     62        // Restores the more descriptive, specific name for use within this method.
     63        $menu_item              = $data_object;
    6064        $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
    6165
    6266        ob_start();
    63         $item_id      = esc_attr( $item->ID );
     67        $item_id      = esc_attr( $menu_item->ID );
    6468        $removed_args = array(
    6569            'action',
     
    7377        $original_title = false;
    7478
    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 );
    7781            if ( $original_object && ! is_wp_error( $original_object ) ) {
    7882                $original_title = $original_object->name;
    7983            }
    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 );
    8286            if ( $original_object ) {
    8387                $original_title = get_the_title( $original_object->ID );
    8488            }
    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 );
    8791            if ( $original_object ) {
    8892                $original_title = $original_object->labels->archives;
     
    9296        $classes = array(
    9397            'menu-item menu-item-depth-' . $depth,
    94             'menu-item-' . esc_attr( $item->object ),
     98            'menu-item-' . esc_attr( $menu_item->object ),
    9599            'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id === $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
    96100        );
    97101
    98         $title = $item->title;
    99 
    100         if ( ! empty( $item->_invalid ) ) {
     102        $title = $menu_item->title;
     103
     104        if ( ! empty( $menu_item->_invalid ) ) {
    101105            $classes[] = 'menu-item-invalid';
    102106            /* 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 ) {
    105109            $classes[] = 'pending';
    106110            /* 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 );
    108112        }
    109113
    110         $title = ( ! isset( $item->label ) || '' === $item->label ) ? $title : $item->label;
     114        $title = ( ! isset( $menu_item->label ) || '' === $menu_item->label ) ? $title : $menu_item->label;
    111115
    112116        $submenu_text = '';
     
    125129                    </label>
    126130                    <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>
    128132                        <span class="item-order hide-if-js">
    129133                            <?php
     
    186190
    187191            <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 ) : ?>
    189193                    <p class="field-url description description-wide">
    190194                        <label for="edit-menu-item-url-<?php echo $item_id; ?>">
    191195                            <?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 ); ?>" />
    193197                        </label>
    194198                    </p>
     
    197201                    <label for="edit-menu-item-title-<?php echo $item_id; ?>">
    198202                        <?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 ); ?>" />
    200204                    </label>
    201205                </p>
     
    203207                    <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
    204208                        <?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 ); ?>" />
    206210                    </label>
    207211                </p>
    208212                <p class="field-link-target description">
    209213                    <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' ); ?> />
    211215                        <?php _e( 'Open link in a new tab' ); ?>
    212216                    </label>
     
    215219                    <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
    216220                        <?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 ) ); ?>" />
    218222                    </label>
    219223                </p>
     
    221225                    <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
    222226                        <?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 ); ?>" />
    224228                    </label>
    225229                </p>
     
    227231                    <label for="edit-menu-item-description-<?php echo $item_id; ?>">
    228232                        <?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>
    230234                        <span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
    231235                    </label>
     
    238242                 * @since 5.4.0
    239243                 *
    240                  * @param int      $item_id Menu item ID.
    241                  * @param WP_Post  $item    Menu 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.
    245249                 */
    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 );
    247251                ?>
    248252
     
    257261
    258262                <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 ) : ?>
    260264                        <p class="link-to-original">
    261265                            <?php
    262266                            /* 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>' );
    264268                            ?>
    265269                        </p>
     
    304308
    305309                <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 ); ?>" />
    311315            </div><!-- .menu-item-settings-->
    312316            <ul class="menu-item-transport"></ul>
  • trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php

    r51322 r51739  
    2121         *
    2222         * @since Twenty Twenty 1.0
     23         * @since Twenty Twenty 1.9 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
    2324         *
    2425         * @see Walker::start_el()
    2526         *
    2627         * @param string  $output       Used to append additional content. Passed by reference.
    27          * @param WP_Post $page         Page data object.
     28         * @param WP_Post $data_object  Page data object.
    2829         * @param int     $depth        Optional. Depth of page. Used for padding. Default 0.
    2930         * @param array   $args         Optional. Array of arguments. Default empty array.
    3031         * @param int     $current_page Optional. Page ID. Default 0.
    3132         */
    32         public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
     33        public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_page = 0 ) {
     34            // Restores the more descriptive, specific name for use within this method.
     35            $page = $data_object;
    3336
    3437            if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
  • trunk/src/wp-includes/class-walker-category-dropdown.php

    r49183 r51739  
    4545     *
    4646     * @since 2.1.0
     47     * @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
    4748     *
    4849     * @see Walker::start_el()
    4950     *
    50      * @param string  $output   Used to append additional content (passed by reference).
    51      * @param WP_Term $category Category data object.
    52      * @param int     $depth    Depth of category. Used for padding.
    53      * @param array   $args     Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
    54      *                          See wp_dropdown_categories().
    55      * @param int     $id       Optional. ID of the current category. Default 0 (unused).
     51     * @param string  $output      Used to append additional content (passed by reference).
     52     * @param WP_Term $data_object Category data object.
     53     * @param int     $depth       Depth of category. Used for padding.
     54     * @param array   $args        Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
     55     *                             See wp_dropdown_categories().
     56     * @param int     $id          Optional. ID of the current category. Default 0 (unused).
    5657     */
    57     public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
    58         $pad = str_repeat( '&nbsp;', $depth * 3 );
     58    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
     59        // Restores the more descriptive, specific name for use within this method.
     60        $category = $data_object;
     61        $pad      = str_repeat( '&nbsp;', $depth * 3 );
    5962
    6063        /** This filter is documented in wp-includes/category-template.php */
  • trunk/src/wp-includes/class-walker-category.php

    r49183 r51739  
    8787     *
    8888     * @since 2.1.0
     89     * @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
    8990     *
    9091     * @see Walker::start_el()
    9192     *
    92      * @param string  $output   Used to append additional content (passed by reference).
    93      * @param WP_Term $category Category data object.
    94      * @param int     $depth    Optional. Depth of category in reference to parents. Default 0.
    95      * @param array   $args     Optional. An array of arguments. See wp_list_categories(). Default empty array.
    96      * @param int     $id       Optional. ID of the current category. Default 0.
    97      */
    98     public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
     93     * @param string  $output      Used to append additional content (passed by reference).
     94     * @param WP_Term $data_object Category data object.
     95     * @param int     $depth       Optional. Depth of category in reference to parents. Default 0.
     96     * @param array   $args        Optional. An array of arguments. See wp_list_categories().
     97     *                             Default empty array.
     98     * @param int     $id          Optional. ID of the current category. Default 0.
     99     */
     100    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
     101        // Restores the more descriptive, specific name for use within this method.
     102        $category = $data_object;
     103
    99104        /** This filter is documented in wp-includes/category-template.php */
    100105        $cat_name = apply_filters( 'list_cats', esc_attr( $category->name ), $category );
  • trunk/src/wp-includes/class-walker-comment.php

    r50816 r51739  
    158158     *
    159159     * @since 2.7.0
     160     * @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support.
    160161     *
    161162     * @see Walker::start_el()
     
    164165     * @global WP_Comment $comment       Global comment object.
    165166     *
    166      * @param string     $output  Used to append additional content. Passed by reference.
    167      * @param WP_Comment $comment Comment data object.
    168      * @param int        $depth   Optional. Depth of the current comment in reference to parents. Default 0.
    169      * @param array      $args    Optional. An array of arguments. Default empty array.
    170      * @param int        $id      Optional. ID of the current comment. Default 0 (unused).
    171      */
    172     public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
     167     * @param string     $output      Used to append additional content. Passed by reference.
     168     * @param WP_Comment $data_object Comment data object.
     169     * @param int        $depth       Optional. Depth of the current comment in reference to parents. Default 0.
     170     * @param array      $args        Optional. An array of arguments. Default empty array.
     171     * @param int        $id          Optional. ID of the current comment. Default 0 (unused).
     172     */
     173    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
     174        // Restores the more descriptive, specific name for use within this method.
     175        $comment = $data_object;
     176
    173177        $depth++;
    174178        $GLOBALS['comment_depth'] = $depth;
  • trunk/src/wp-includes/class-walker-nav-menu.php

    r50823 r51739  
    107107     * @since 3.0.0
    108108     * @since 4.4.0 The {@see 'nav_menu_item_args'} filter was added.
     109     * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
    109110     *
    110111     * @see Walker::start_el()
    111112     *
    112      * @param string   $output Used to append additional content (passed by reference).
    113      * @param WP_Post  $item   Menu item data object.
    114      * @param int      $depth  Depth of menu item. Used for padding.
    115      * @param stdClass $args   An object of wp_nav_menu() arguments.
    116      * @param int      $id     Current item ID.
    117      */
    118     public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
     113     * @param string   $output      Used to append additional content (passed by reference).
     114     * @param WP_Post  $data_object Menu item data object.
     115     * @param int      $depth       Depth of menu item. Used for padding.
     116     * @param stdClass $args        An object of wp_nav_menu() arguments.
     117     * @param int      $id          Current item ID.
     118     */
     119    public function start_el( &$output, $data_object, $depth = 0, $args = null, $id = 0 ) {
     120        // Restores the more descriptive, specific name for use within this method.
     121        $menu_item = $data_object;
     122
    119123        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    120124            $t = '';
     
    126130        $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
    127131
    128         $classes   = empty( $item->classes ) ? array() : (array) $item->classes;
    129         $classes[] = 'menu-item-' . $item->ID;
     132        $classes   = empty( $menu_item->classes ) ? array() : (array) $menu_item->classes;
     133        $classes[] = 'menu-item-' . $menu_item->ID;
    130134
    131135        /**
     
    134138         * @since 4.4.0
    135139         *
    136          * @param stdClass $args  An object of wp_nav_menu() arguments.
    137          * @param WP_Post  $item Menu item data object.
    138          * @param int      $depth Depth of menu item. Used for padding.
    139          */
    140         $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
     140         * @param stdClass $args      An object of wp_nav_menu() arguments.
     141         * @param WP_Post  $menu_item Menu item data object.
     142         * @param int      $depth     Depth of menu item. Used for padding.
     143         */
     144        $args = apply_filters( 'nav_menu_item_args', $args, $menu_item, $depth );
    141145
    142146        /**
     
    146150         * @since 4.1.0 The `$depth` parameter was added.
    147151         *
    148          * @param string[] $classes Array of the CSS classes that are applied to the menu item's `<li>` element.
    149          * @param WP_Post  $item    The current menu item.
    150          * @param stdClass $args    An object of wp_nav_menu() arguments.
    151          * @param int      $depth   Depth of menu item. Used for padding.
    152          */
    153         $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
     152         * @param string[] $classes   Array of the CSS classes that are applied to the menu item's `<li>` element.
     153         * @param WP_Post  $menu_item The current menu item object.
     154         * @param stdClass $args      An object of wp_nav_menu() arguments.
     155         * @param int      $depth     Depth of menu item. Used for padding.
     156         */
     157        $class_names = implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $menu_item, $args, $depth ) );
    154158        $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
    155159
     
    160164         * @since 4.1.0 The `$depth` parameter was added.
    161165         *
    162          * @param string   $menu_id The ID that is applied to the menu item's `<li>` element.
    163          * @param WP_Post  $item    The current menu item.
    164          * @param stdClass $args    An object of wp_nav_menu() arguments.
    165          * @param int      $depth   Depth of menu item. Used for padding.
    166          */
    167         $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth );
     166         * @param string   $menu_id   The ID that is applied to the menu item's `<li>` element.
     167         * @param WP_Post  $menu_item The current menu item.
     168         * @param stdClass $args      An object of wp_nav_menu() arguments.
     169         * @param int      $depth     Depth of menu item. Used for padding.
     170         */
     171        $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $menu_item->ID, $menu_item, $args, $depth );
    168172        $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
    169173
     
    171175
    172176        $atts           = array();
    173         $atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
    174         $atts['target'] = ! empty( $item->target ) ? $item->target : '';
    175         if ( '_blank' === $item->target && empty( $item->xfn ) ) {
     177        $atts['title']  = ! empty( $menu_item->attr_title ) ? $menu_item->attr_title : '';
     178        $atts['target'] = ! empty( $menu_item->target ) ? $menu_item->target : '';
     179        if ( '_blank' === $menu_item->target && empty( $menu_item->xfn ) ) {
    176180            $atts['rel'] = 'noopener';
    177181        } else {
    178             $atts['rel'] = $item->xfn;
    179         }
    180         $atts['href']         = ! empty( $item->url ) ? $item->url : '';
    181         $atts['aria-current'] = $item->current ? 'page' : '';
     182            $atts['rel'] = $menu_item->xfn;
     183        }
     184        $atts['href']         = ! empty( $menu_item->url ) ? $menu_item->url : '';
     185        $atts['aria-current'] = $menu_item->current ? 'page' : '';
    182186
    183187        /**
     
    196200         *     @type string $aria-current The aria-current attribute.
    197201         * }
    198          * @param WP_Post  $item  The current menu item.
    199          * @param stdClass $args  An object of wp_nav_menu() arguments.
    200          * @param int      $depth Depth of menu item. Used for padding.
    201          */
    202         $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
     202         * @param WP_Post  $menu_item The current menu item object.
     203         * @param stdClass $args      An object of wp_nav_menu() arguments.
     204         * @param int      $depth     Depth of menu item. Used for padding.
     205         */
     206        $atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
    203207
    204208        $attributes = '';
     
    211215
    212216        /** This filter is documented in wp-includes/post-template.php */
    213         $title = apply_filters( 'the_title', $item->title, $item->ID );
     217        $title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
    214218
    215219        /**
     
    218222         * @since 4.4.0
    219223         *
    220          * @param string   $title The menu item's title.
    221          * @param WP_Post  $item  The current menu item.
    222          * @param stdClass $args  An object of wp_nav_menu() arguments.
    223          * @param int      $depth Depth of menu item. Used for padding.
    224          */
    225         $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
     224         * @param string   $title     The menu item's title.
     225         * @param WP_Post  $menu_item The current menu item object.
     226         * @param stdClass $args      An object of wp_nav_menu() arguments.
     227         * @param int      $depth     Depth of menu item. Used for padding.
     228         */
     229        $title = apply_filters( 'nav_menu_item_title', $title, $menu_item, $args, $depth );
    226230
    227231        $item_output  = $args->before;
     
    241245         *
    242246         * @param string   $item_output The menu item's starting HTML output.
    243          * @param WP_Post  $item        Menu item data object.
     247         * @param WP_Post  $menu_item   Menu item data object.
    244248         * @param int      $depth       Depth of menu item. Used for padding.
    245249         * @param stdClass $args        An object of wp_nav_menu() arguments.
    246250         */
    247         $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
     251        $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $menu_item, $depth, $args );
    248252    }
    249253
  • trunk/src/wp-includes/class-walker-page-dropdown.php

    r45932 r51739  
    4545     *
    4646     * @since 2.1.0
     47     * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
    4748     *
    4849     * @see Walker::start_el()
    4950     *
    50      * @param string  $output Used to append additional content. Passed by reference.
    51      * @param WP_Post $page  Page data object.
    52      * @param int     $depth  Optional. Depth of page in reference to parent pages. Used for padding.
    53      *                        Default 0.
    54      * @param array   $args   Optional. Uses 'selected' argument for selected page to set selected HTML
    55      *                        attribute for option element. Uses 'value_field' argument to fill "value"
    56      *                        attribute. See wp_dropdown_pages(). Default empty array.
    57      * @param int     $id     Optional. ID of the current page. Default 0 (unused).
     51     * @param string  $output      Used to append additional content. Passed by reference.
     52     * @param WP_Post $data_object Page data object.
     53     * @param int     $depth       Optional. Depth of page in reference to parent pages. Used for padding.
     54     *                             Default 0.
     55     * @param array   $args        Optional. Uses 'selected' argument for selected page to set selected HTML
     56     *                             attribute for option element. Uses 'value_field' argument to fill "value"
     57     *                             attribute. See wp_dropdown_pages(). Default empty array.
     58     * @param int     $id          Optional. ID of the current page. Default 0 (unused).
    5859     */
    59     public function start_el( &$output, $page, $depth = 0, $args = array(), $id = 0 ) {
    60         $pad = str_repeat( '&nbsp;', $depth * 3 );
     60    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $id = 0 ) {
     61        // Restores the more descriptive, specific name for use within this method.
     62        $page = $data_object;
     63        $pad  = str_repeat( '&nbsp;', $depth * 3 );
    6164
    6265        if ( ! isset( $args['value_field'] ) || ! isset( $page->{$args['value_field']} ) ) {
  • trunk/src/wp-includes/class-walker-page.php

    r50823 r51739  
    9494     * @see Walker::start_el()
    9595     * @since 2.1.0
     96     * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
    9697     *
    9798     * @param string  $output       Used to append additional content. Passed by reference.
    98      * @param WP_Post $page         Page data object.
     99     * @param WP_Post $data_object  Page data object.
    99100     * @param int     $depth        Optional. Depth of page. Used for padding. Default 0.
    100101     * @param array   $args         Optional. Array of arguments. Default empty array.
    101102     * @param int     $current_page Optional. Page ID. Default 0.
    102103     */
    103     public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
     104    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_page = 0 ) {
     105        // Restores the more descriptive, specific name for use within this method.
     106        $page = $data_object;
     107
    104108        if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
    105109            $t = "\t";
  • trunk/src/wp-includes/class-wp-walker.php

    r51204 r51739  
    8484     *
    8585     * @since 2.1.0
     86     * @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.
    8687     * @abstract
    8788     *
    8889     * @param string $output            Used to append additional content (passed by reference).
    89      * @param object $object            The data object.
     90     * @param object $data_object       The data object.
    9091     * @param int    $depth             Depth of the item.
    9192     * @param array  $args              An array of additional arguments.
    9293     * @param int    $current_object_id ID of the current item.
    9394     */
    94     public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
     95    public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
    9596
    9697    /**
Note: See TracChangeset for help on using the changeset viewer.