Make WordPress Core

Changeset 53116


Ignore:
Timestamp:
04/09/2022 08:36:53 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/class-wp-posts-list-table.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit:

  • Renames the $class parameter to $css_class in WP_Posts_List_Table::get_edit_link().
  • Renames the $parent parameter to $parent_page in WP_Posts_List_Table::_page_rows().

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r53105 r53116  
    252252     * @since 4.4.0
    253253     *
    254      * @param string[] $args  Associative array of URL parameters for the link.
    255      * @param string   $label Link text.
    256      * @param string   $class Optional. Class attribute. Default empty string.
     254     * @param string[] $args      Associative array of URL parameters for the link.
     255     * @param string   $link_text Link text.
     256     * @param string   $css_class Optional. Class attribute. Default empty string.
    257257     * @return string The formatted link string.
    258258     */
    259     protected function get_edit_link( $args, $label, $class = '' ) {
     259    protected function get_edit_link( $args, $link_text, $css_class = '' ) {
    260260        $url = add_query_arg( $args, 'edit.php' );
    261261
     
    263263        $aria_current = '';
    264264
    265         if ( ! empty( $class ) ) {
     265        if ( ! empty( $css_class ) ) {
    266266            $class_html = sprintf(
    267267                ' class="%s"',
    268                 esc_attr( $class )
     268                esc_attr( $css_class )
    269269            );
    270270
    271             if ( 'current' === $class ) {
     271            if ( 'current' === $css_class ) {
    272272                $aria_current = ' aria-current="page"';
    273273            }
     
    279279            $class_html,
    280280            $aria_current,
    281             $label
     281            $link_text
    282282        );
    283283    }
     
    906906     * @param array $children_pages
    907907     * @param int   $count
    908      * @param int   $parent
     908     * @param int   $parent_page
    909909     * @param int   $level
    910910     * @param int   $pagenum
     
    912912     * @param array $to_display List of pages to be displayed. Passed by reference.
    913913     */
    914     private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
    915         if ( ! isset( $children_pages[ $parent ] ) ) {
     914    private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) {
     915        if ( ! isset( $children_pages[ $parent_page ] ) ) {
    916916            return;
    917917        }
     
    920920        $end   = $start + $per_page;
    921921
    922         foreach ( $children_pages[ $parent ] as $page ) {
     922        foreach ( $children_pages[ $parent_page ] as $page ) {
    923923            if ( $count >= $end ) {
    924924                break;
     
    965965        }
    966966
    967         unset( $children_pages[ $parent ] ); // Required in order to keep track of orphans.
     967        unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans.
    968968    }
    969969
Note: See TracChangeset for help on using the changeset viewer.