Skip to content

Commit

Permalink
Coding Standards: Use strict comparison in `wp-admin/includes/class-w…
Browse files Browse the repository at this point in the history
…p-terms-list-table.php`.

Includes minor code layout fixes for better readability.

See #52627.

git-svn-id: https://develop.svn.wordpress.org/trunk@50780 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Apr 21, 2021
1 parent c687dc1 commit 5aae96b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/wp-admin/includes/class-wp-terms-list-table.php
Expand Up @@ -292,27 +292,32 @@ private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$coun
break;
}

if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) {
if ( $term->parent !== $parent && empty( $_REQUEST['s'] ) ) {
continue;
}

// If the page starts in a subtree, print the parents.
if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
if ( $count === $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
$my_parents = array();
$parent_ids = array();
$p = $term->parent;

while ( $p ) {
$my_parent = get_term( $p, $taxonomy );
$my_parents[] = $my_parent;
$p = $my_parent->parent;

if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops.
break;
}

$parent_ids[] = $p;
}

unset( $parent_ids );

$num_parents = count( $my_parents );

while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t";
$this->single_row( $my_parent, $level - $num_parents );
Expand Down Expand Up @@ -474,6 +479,7 @@ protected function handle_row_actions( $tag, $column_name, $primary ) {
);

$actions = array();

if ( current_user_can( 'edit_term', $tag->term_id ) ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
Expand All @@ -489,6 +495,7 @@ protected function handle_row_actions( $tag, $column_name, $primary ) {
__( 'Quick&nbsp;Edit' )
);
}

if ( current_user_can( 'delete_term', $tag->term_id ) ) {
$actions['delete'] = sprintf(
'<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',
Expand All @@ -498,6 +505,7 @@ protected function handle_row_actions( $tag, $column_name, $primary ) {
__( 'Delete' )
);
}

if ( is_taxonomy_viewable( $tax ) ) {
$actions['view'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
Expand Down Expand Up @@ -603,9 +611,11 @@ public function column_posts( $tag ) {
*/
public function column_links( $tag ) {
$count = number_format_i18n( $tag->count );

if ( $count ) {
$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
}

return $count;
}

Expand Down

0 comments on commit 5aae96b

Please sign in to comment.