From 8c52bfe71249a9e8c6529a8d60f94e465a36a512 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 27 Sep 2021 00:37:01 +0000 Subject: [PATCH] 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: * [12897], [15491], [32755], [46153], [48424] for `WP_MS_Sites_List_Table::site_states()`. * [17793], [47775], [49223] for `_media_states()`. * [9153], [46309] for `_post_states()`. Props joelcj91, audrasjb, desrosj. Fixes #38296. Built from https://develop.svn.wordpress.org/trunk@51873 git-svn-id: http://core.svn.wordpress.org/trunk@51466 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-ms-sites-list-table.php | 9 +++++++-- wp-admin/includes/template.php | 14 ++++++++++---- wp-includes/version.php | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php index 64cab8cecb..b185664bd6 100644 --- a/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -643,11 +643,16 @@ class WP_MS_Sites_List_Table extends WP_List_Table { if ( ! empty( $site_states ) ) { $state_count = count( $site_states ); - $i = 0; + + $i = 0; + echo ' — '; + foreach ( $site_states as $state ) { ++$i; - ( $i == $state_count ) ? $sep = '' : $sep = ', '; + + $sep = ( $i < $state_count ) ? ', ' : ''; + echo "{$state}{$sep}"; } } diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 83df709754..4228d931ba 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -2145,12 +2145,15 @@ function _post_states( $post, $echo = true ) { if ( ! empty( $post_states ) ) { $state_count = count( $post_states ); - $i = 0; + + $i = 0; $post_states_string .= ' — '; foreach ( $post_states as $state ) { - $sep = ( ++$i === $state_count ) ? '' : ', '; + ++$i; + + $sep = ( $i < $state_count ) ? ', ' : ''; $post_states_string .= "$state$sep"; } @@ -2255,12 +2258,15 @@ function _media_states( $post, $echo = true ) { if ( ! empty( $media_states ) ) { $state_count = count( $media_states ); - $i = 0; + + $i = 0; $media_states_string .= ' — '; foreach ( $media_states as $state ) { - $sep = ( ++$i === $state_count ) ? '' : ', '; + ++$i; + + $sep = ( $i < $state_count ) ? ', ' : ''; $media_states_string .= "$state$sep"; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 99b7400cee..dda130caa0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51872'; +$wp_version = '5.9-alpha-51873'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.