Skip to content

Commit 4287e30

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60132 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3e3e00e commit 4287e30

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,15 +1524,12 @@ public function print_column_headers( $with_id = true ) {
15241524
);
15251525
}
15261526

1527-
$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
1528-
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1529-
$id = $with_id ? "id='$column_key'" : '';
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 ) . "'";
15301531

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>";
1532+
echo "<$tag $scope $id $class_attr $aria_sort_attr $abbr_attr>$column_display_name</$tag>";
15361533
}
15371534
}
15381535

0 commit comments

Comments
 (0)