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.
Built from https://develop.svn.wordpress.org/trunk@53116


git-svn-id: http://core.svn.wordpress.org/trunk@52705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-09 20:38:04 +00:00
parent 1d65842848
commit 483a0e38e8
2 changed files with 14 additions and 14 deletions

View File

@ -251,24 +251,24 @@ class WP_Posts_List_Table extends WP_List_Table {
* *
* @since 4.4.0 * @since 4.4.0
* *
* @param string[] $args Associative array of URL parameters for the link. * @param string[] $args Associative array of URL parameters for the link.
* @param string $label Link text. * @param string $link_text Link text.
* @param string $class Optional. Class attribute. Default empty string. * @param string $css_class Optional. Class attribute. Default empty string.
* @return string The formatted link string. * @return string The formatted link string.
*/ */
protected function get_edit_link( $args, $label, $class = '' ) { protected function get_edit_link( $args, $link_text, $css_class = '' ) {
$url = add_query_arg( $args, 'edit.php' ); $url = add_query_arg( $args, 'edit.php' );
$class_html = ''; $class_html = '';
$aria_current = ''; $aria_current = '';
if ( ! empty( $class ) ) { if ( ! empty( $css_class ) ) {
$class_html = sprintf( $class_html = sprintf(
' class="%s"', ' class="%s"',
esc_attr( $class ) esc_attr( $css_class )
); );
if ( 'current' === $class ) { if ( 'current' === $css_class ) {
$aria_current = ' aria-current="page"'; $aria_current = ' aria-current="page"';
} }
} }
@ -278,7 +278,7 @@ class WP_Posts_List_Table extends WP_List_Table {
esc_url( $url ), esc_url( $url ),
$class_html, $class_html,
$aria_current, $aria_current,
$label $link_text
); );
} }
@ -905,21 +905,21 @@ class WP_Posts_List_Table extends WP_List_Table {
* *
* @param array $children_pages * @param array $children_pages
* @param int $count * @param int $count
* @param int $parent * @param int $parent_page
* @param int $level * @param int $level
* @param int $pagenum * @param int $pagenum
* @param int $per_page * @param int $per_page
* @param array $to_display List of pages to be displayed. Passed by reference. * @param array $to_display List of pages to be displayed. Passed by reference.
*/ */
private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) {
if ( ! isset( $children_pages[ $parent ] ) ) { if ( ! isset( $children_pages[ $parent_page ] ) ) {
return; return;
} }
$start = ( $pagenum - 1 ) * $per_page; $start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page; $end = $start + $per_page;
foreach ( $children_pages[ $parent ] as $page ) { foreach ( $children_pages[ $parent_page ] as $page ) {
if ( $count >= $end ) { if ( $count >= $end ) {
break; break;
} }
@ -964,7 +964,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
} }
unset( $children_pages[ $parent ] ); // Required in order to keep track of orphans. unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans.
} }
/** /**

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-alpha-53115'; $wp_version = '6.0-alpha-53116';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.