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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53116 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-04-09 20:36:53 +00:00
parent 5a1262f02b
commit fdc6380337

View File

@ -251,24 +251,24 @@ class WP_Posts_List_Table extends WP_List_Table {
*
* @since 4.4.0
*
* @param string[] $args Associative array of URL parameters for the link.
* @param string $label Link text.
* @param string $class Optional. Class attribute. Default empty string.
* @param string[] $args Associative array of URL parameters for the link.
* @param string $link_text Link text.
* @param string $css_class Optional. Class attribute. Default empty 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' );
$class_html = '';
$aria_current = '';
if ( ! empty( $class ) ) {
if ( ! empty( $css_class ) ) {
$class_html = sprintf(
' class="%s"',
esc_attr( $class )
esc_attr( $css_class )
);
if ( 'current' === $class ) {
if ( 'current' === $css_class ) {
$aria_current = ' aria-current="page"';
}
}
@ -278,7 +278,7 @@ class WP_Posts_List_Table extends WP_List_Table {
esc_url( $url ),
$class_html,
$aria_current,
$label
$link_text
);
}
@ -905,21 +905,21 @@ class WP_Posts_List_Table extends WP_List_Table {
*
* @param array $children_pages
* @param int $count
* @param int $parent
* @param int $parent_page
* @param int $level
* @param int $pagenum
* @param int $per_page
* @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 ) {
if ( ! isset( $children_pages[ $parent ] ) ) {
private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) {
if ( ! isset( $children_pages[ $parent_page ] ) ) {
return;
}
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $children_pages[ $parent ] as $page ) {
foreach ( $children_pages[ $parent_page ] as $page ) {
if ( $count >= $end ) {
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 );
}
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.
}
/**