Coding Standards: Use more meaningful variable names for output in the admin.

This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.

This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`

Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].

Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071


git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-09-05 17:19:09 +00:00
parent cdfb7d7ef0
commit c54960342b
11 changed files with 47 additions and 45 deletions

View File

@ -677,7 +677,7 @@ class WP_Comments_List_Table extends WP_List_Table {
$comment = $item; $comment = $item;
$the_comment_status = wp_get_comment_status( $comment ); $the_comment_status = wp_get_comment_status( $comment );
$out = ''; $output = '';
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
@ -832,7 +832,7 @@ class WP_Comments_List_Table extends WP_List_Table {
$always_visible = true; $always_visible = true;
} }
$out .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; $output .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
$i = 0; $i = 0;
@ -842,9 +842,9 @@ class WP_Comments_List_Table extends WP_List_Table {
if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
|| 1 === $i || 1 === $i
) { ) {
$sep = ''; $separator = '';
} else { } else {
$sep = ' | '; $separator = ' | ';
} }
// Reply and quickedit need a hide-if-no-js span when not added with Ajax. // Reply and quickedit need a hide-if-no-js span when not added with Ajax.
@ -860,14 +860,14 @@ class WP_Comments_List_Table extends WP_List_Table {
} }
} }
$out .= "<span class='$action'>$sep$link</span>"; $output .= "<span class='$action'>{$separator}{$link}</span>";
} }
$out .= '</div>'; $output .= '</div>';
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; $output .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
return $out; return $output;
} }
/** /**

View File

@ -555,23 +555,23 @@ class WP_List_Table {
$always_visible = true; $always_visible = true;
} }
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; $output = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
$i = 0; $i = 0;
foreach ( $actions as $action => $link ) { foreach ( $actions as $action => $link ) {
++$i; ++$i;
$sep = ( $i < $action_count ) ? ' | ' : ''; $separator = ( $i < $action_count ) ? ' | ' : '';
$out .= "<span class='$action'>$link$sep</span>"; $output .= "<span class='$action'>{$link}{$separator}</span>";
} }
$out .= '</div>'; $output .= '</div>';
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; $output .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
return $out; return $output;
} }
/** /**

View File

@ -635,19 +635,21 @@ class WP_Media_List_Table extends WP_List_Table {
$terms = get_the_terms( $post->ID, $taxonomy ); $terms = get_the_terms( $post->ID, $taxonomy );
if ( is_array( $terms ) ) { if ( is_array( $terms ) ) {
$out = array(); $output = array();
foreach ( $terms as $t ) { foreach ( $terms as $t ) {
$posts_in_term_qv = array(); $posts_in_term_qv = array();
$posts_in_term_qv['taxonomy'] = $taxonomy; $posts_in_term_qv['taxonomy'] = $taxonomy;
$posts_in_term_qv['term'] = $t->slug; $posts_in_term_qv['term'] = $t->slug;
$out[] = sprintf( $output[] = sprintf(
'<a href="%s">%s</a>', '<a href="%s">%s</a>',
esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
); );
} }
echo implode( wp_get_list_item_separator(), $out );
echo implode( wp_get_list_item_separator(), $output );
} else { } else {
echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';
} }

View File

@ -651,9 +651,9 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
foreach ( $site_states as $state ) { foreach ( $site_states as $state ) {
++$i; ++$i;
$sep = ( $i < $state_count ) ? ', ' : ''; $separator = ( $i < $state_count ) ? ', ' : '';
echo "<span class='post-state'>{$state}{$sep}</span>"; echo "<span class='post-state'>{$state}{$separator}</span>";
} }
} }
} }

View File

@ -438,9 +438,9 @@ class WP_MS_Users_List_Table extends WP_List_Table {
foreach ( $actions as $action => $link ) { foreach ( $actions as $action => $link ) {
++$i; ++$i;
$sep = ( $i < $action_count ) ? ' | ' : ''; $separator = ( $i < $action_count ) ? ' | ' : '';
echo "<span class='$action'>$link$sep</span>"; echo "<span class='$action'>{$link}{$separator}</span>";
} }
echo '</small></span><br />'; echo '</small></span><br />';

View File

@ -414,19 +414,19 @@ class WP_Terms_List_Table extends WP_List_Table {
); );
} }
$out = sprintf( $output = sprintf(
'<strong>%s</strong><br />', '<strong>%s</strong><br />',
$name $name
); );
$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
$out .= '<div class="name">' . $qe_data->name . '</div>'; $output .= '<div class="name">' . $qe_data->name . '</div>';
/** This filter is documented in wp-admin/edit-tag-form.php */ /** This filter is documented in wp-admin/edit-tag-form.php */
$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
$out .= '<div class="parent">' . $qe_data->parent . '</div></div>'; $output .= '<div class="parent">' . $qe_data->parent . '</div></div>';
return $out; return $output;
} }
/** /**

View File

@ -799,9 +799,9 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
|| 1 === $i || 1 === $i
) { ) {
$sep = ''; $separator = '';
} else { } else {
$sep = ' | '; $separator = ' | ';
} }
// Reply and quickedit need a hide-if-no-js span. // Reply and quickedit need a hide-if-no-js span.
@ -813,7 +813,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$action .= ' hidden'; $action .= ' hidden';
} }
$actions_string .= "<span class='$action'>$sep$link</span>"; $actions_string .= "<span class='$action'>{$separator}{$link}</span>";
} }
} }
?> ?>

View File

@ -1155,16 +1155,16 @@ function image_align_input_fields( $post, $checked = '' ) {
$checked = 'none'; $checked = 'none';
} }
$out = array(); $output = array();
foreach ( $alignments as $name => $label ) { foreach ( $alignments as $name => $label ) {
$name = esc_attr( $name ); $name = esc_attr( $name );
$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" . $output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
( $checked == $name ? " checked='checked'" : '' ) . ( $checked == $name ? " checked='checked'" : '' ) .
" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
} }
return implode( "\n", $out ); return implode( "\n", $output );
} }
/** /**
@ -1199,7 +1199,7 @@ function image_size_input_fields( $post, $check = '' ) {
$check = get_user_setting( 'imgsize', 'medium' ); $check = get_user_setting( 'imgsize', 'medium' );
} }
$out = array(); $output = array();
foreach ( $size_names as $size => $label ) { foreach ( $size_names as $size => $label ) {
$downsize = image_downsize( $post->ID, $size ); $downsize = image_downsize( $post->ID, $size );
@ -1235,13 +1235,13 @@ function image_size_input_fields( $post, $check = '' ) {
} }
$html .= '</div>'; $html .= '</div>';
$out[] = $html; $output[] = $html;
} }
return array( return array(
'label' => __( 'Size' ), 'label' => __( 'Size' ),
'input' => 'html', 'input' => 'html',
'html' => implode( "\n", $out ), 'html' => implode( "\n", $output ),
); );
} }

View File

@ -663,17 +663,17 @@ function wp_doc_link_parse( $content ) {
$ignore_functions = array_unique( $ignore_functions ); $ignore_functions = array_unique( $ignore_functions );
$out = array(); $output = array();
foreach ( $functions as $function ) { foreach ( $functions as $function ) {
if ( in_array( $function, $ignore_functions, true ) ) { if ( in_array( $function, $ignore_functions, true ) ) {
continue; continue;
} }
$out[] = $function; $output[] = $function;
} }
return $out; return $output;
} }
/** /**

View File

@ -2168,9 +2168,9 @@ function _post_states( $post, $display = true ) {
foreach ( $post_states as $state ) { foreach ( $post_states as $state ) {
++$i; ++$i;
$sep = ( $i < $state_count ) ? ', ' : ''; $separator = ( $i < $state_count ) ? ', ' : '';
$post_states_string .= "<span class='post-state'>$state$sep</span>"; $post_states_string .= "<span class='post-state'>{$state}{$separator}</span>";
} }
} }
@ -2282,9 +2282,9 @@ function _media_states( $post, $display = true ) {
foreach ( $media_states as $state ) { foreach ( $media_states as $state ) {
++$i; ++$i;
$sep = ( $i < $state_count ) ? ', ' : ''; $separator = ( $i < $state_count ) ? ', ' : '';
$media_states_string .= "<span class='post-state'>$state$sep</span>"; $media_states_string .= "<span class='post-state'>{$state}{$separator}</span>";
} }
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.1-alpha-54070'; $wp_version = '6.1-alpha-54071';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.