Coding Standards: Use strict comparison in media_upload_library_form().

Includes bringing some consistency with a similar fragment in `WP_List_Table::months_dropdown()`.

Follow-up to [3724], [7062], [15491], [59755].

Props aristath, poena, afercia, SergeyBiryukov.
See #62279.
Built from https://develop.svn.wordpress.org/trunk@59767


git-svn-id: http://core.svn.wordpress.org/trunk@59109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2025-02-06 12:24:24 +00:00
parent 38025026ac
commit f548f56548
3 changed files with 24 additions and 25 deletions

View File

@ -780,9 +780,9 @@ class WP_List_Table {
printf( printf(
"<option %s value='%s'>%s</option>\n", "<option %s value='%s'>%s</option>\n",
selected( $selected_month, $year . $month, false ), selected( $selected_month, $year . $month, false ),
esc_attr( $arc_row->year . $month ), esc_attr( $year . $month ),
/* translators: 1: Month name, 2: 4-digit year. */ /* translators: 1: Month name, 2: 4-digit year. */
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) esc_html( sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) )
); );
} }
?> ?>

View File

@ -2845,38 +2845,37 @@ function media_upload_library_form( $errors ) {
<div class="alignleft actions"> <div class="alignleft actions">
<?php <?php
$months = $wpdb->get_results(
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts
WHERE post_type = 'attachment'
ORDER BY post_date DESC"
);
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; $month_count = count( $months );
$selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
$arc_result = $wpdb->get_results( $arc_query ); if ( $month_count && ( 1 !== $month_count || 0 !== (int) $months[0]->month ) ) {
$month_count = count( $arc_result );
$selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
?> ?>
<select name='m'> <select name='m'>
<option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
<?php <?php
foreach ( $months as $arc_row ) {
foreach ( $arc_result as $arc_row ) { if ( 0 === (int) $arc_row->year ) {
if ( 0 == $arc_row->yyear ) {
continue; continue;
} }
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); $month = zeroise( $arc_row->month, 2 );
$year = $arc_row->year;
if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) { printf(
$default = ' selected="selected"'; "<option %s value='%s'>%s</option>\n",
} else { selected( $selected_month, $year . $month, false ),
$default = ''; esc_attr( $year . $month ),
} /* translators: 1: Month name, 2: 4-digit year. */
esc_html( sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) )
echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; );
echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" );
echo "</option>\n";
} }
?> ?>
</select> </select>
<?php } ?> <?php } ?>

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.8-alpha-59766'; $wp_version = '6.8-alpha-59767';
/** /**
* 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.