Make WordPress Core

Changeset 51873


Ignore:
Timestamp:
09/27/2021 12:35:38 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove duplicate assignment from a ternary operator in WP_MS_Sites_List_Table::site_states().

Adjust similar code in _post_states() and _media_states() for consistency.

Follow-up to:

Props joelcj91, audrasjb, desrosj.
Fixes #38296.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

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

    r51737 r51873  
    644644        if ( ! empty( $site_states ) ) {
    645645            $state_count = count( $site_states );
    646             $i           = 0;
     646
     647            $i = 0;
     648
    647649            echo ' — ';
     650
    648651            foreach ( $site_states as $state ) {
    649652                ++$i;
    650                 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
     653
     654                $sep = ( $i < $state_count ) ? ', ' : '';
     655
    651656                echo "<span class='post-state'>{$state}{$sep}</span>";
    652657            }
  • trunk/src/wp-admin/includes/template.php

    r51189 r51873  
    21462146    if ( ! empty( $post_states ) ) {
    21472147        $state_count = count( $post_states );
    2148         $i           = 0;
     2148
     2149        $i = 0;
    21492150
    21502151        $post_states_string .= ' &mdash; ';
    21512152
    21522153        foreach ( $post_states as $state ) {
    2153             $sep = ( ++$i === $state_count ) ? '' : ', ';
     2154            ++$i;
     2155
     2156            $sep = ( $i < $state_count ) ? ', ' : '';
    21542157
    21552158            $post_states_string .= "<span class='post-state'>$state$sep</span>";
     
    22562259    if ( ! empty( $media_states ) ) {
    22572260        $state_count = count( $media_states );
    2258         $i           = 0;
     2261
     2262        $i = 0;
    22592263
    22602264        $media_states_string .= ' &mdash; ';
    22612265
    22622266        foreach ( $media_states as $state ) {
    2263             $sep = ( ++$i === $state_count ) ? '' : ', ';
     2267            ++$i;
     2268
     2269            $sep = ( $i < $state_count ) ? ', ' : '';
    22642270
    22652271            $media_states_string .= "<span class='post-state'>$state$sep</span>";
Note: See TracChangeset for help on using the changeset viewer.