Make WordPress Core

Changeset 60132


Ignore:
Timestamp:
04/06/2025 08:54:08 PM (3 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove unnecessary conditional in WP_List_Table::print_column_headers().

This commit removes an unnecessary empty() check, where the $class variable is primed at the top of the foreach loop and will always be a non-empty array.

To maintain readability of the source of the $class attribute without the unnecessary empty() check, the resulting variable has been renamed to $class_attr, instead of reusing the array.

Follow-up to [8923], [15491].

Props justlevine.
See #52217.

File:
1 edited

Legend:

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

    r59767 r60132  
    15251525            }
    15261526
    1527             $tag   = ( 'cb' === $column_key ) ? 'td' : 'th';
    1528             $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
    1529             $id    = $with_id ? "id='$column_key'" : '';
    1530 
    1531             if ( ! empty( $class ) ) {
    1532                 $class = "class='" . implode( ' ', $class ) . "'";
    1533             }
    1534 
    1535             echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>";
     1527            $tag        = ( 'cb' === $column_key ) ? 'td' : 'th';
     1528            $scope      = ( 'th' === $tag ) ? 'scope="col"' : '';
     1529            $id         = $with_id ? "id='$column_key'" : '';
     1530            $class_attr = "class='" . implode( ' ', $class ) . "'";
     1531
     1532            echo "<$tag $scope $id $class_attr $aria_sort_attr $abbr_attr>$column_display_name</$tag>";
    15361533        }
    15371534    }
Note: See TracChangeset for help on using the changeset viewer.