--- a/wp/wp-admin/includes/media.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-admin/includes/media.php Fri Sep 05 18:52:52 2025 +0200
@@ -93,7 +93,7 @@
foreach ( $tabs as $callback => $text ) {
$class = '';
- if ( $current == $callback ) {
+ if ( $current === $callback ) {
$class = " class='current'";
}
@@ -773,7 +773,7 @@
$post['menu_order'] = $attachment['menu_order'];
}
- if ( isset( $send_id ) && $attachment_id == $send_id ) {
+ if ( isset( $send_id ) && $attachment_id === $send_id ) {
if ( isset( $attachment['post_parent'] ) ) {
$post['post_parent'] = $attachment['post_parent'];
}
@@ -1172,7 +1172,7 @@
foreach ( $alignments as $name => $label ) {
$name = esc_attr( $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>";
}
@@ -1222,7 +1222,7 @@
$css_id = "image-size-{$size}-{$post->ID}";
// If this size is the default but that's not available, don't select it.
- if ( $size == $check ) {
+ if ( $size === $check ) {
if ( $enabled ) {
$checked = " checked='checked'";
} else {
@@ -1762,7 +1762,7 @@
if ( 'image' === $type && $calling_post_id
&& current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
&& post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' )
- && get_post_thumbnail_id( $calling_post_id ) != $attachment_id
+ && get_post_thumbnail_id( $calling_post_id ) !== $attachment_id
) {
$calling_post = get_post( $calling_post_id );
@@ -2194,14 +2194,19 @@
$plupload_init['multi_selection'] = false;
}
- // Check if WebP images can be edited.
- if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
- $plupload_init['webp_upload_error'] = true;
- }
-
- // Check if AVIF images can be edited.
- if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
- $plupload_init['avif_upload_error'] = true;
+ /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
+ $prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, null );
+
+ if ( $prevent_unsupported_uploads ) {
+ // Check if WebP images can be edited.
+ if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
+ $plupload_init['webp_upload_error'] = true;
+ }
+
+ // Check if AVIF images can be edited.
+ if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) {
+ $plupload_init['avif_upload_error'] = true;
+ }
}
/**
@@ -2277,11 +2282,11 @@
<label class="screen-reader-text" for="async-upload">
<?php
/* translators: Hidden accessibility text. */
- _e( 'Upload' );
+ _ex( 'Upload', 'verb' );
?>
</label>
<input type="file" name="async-upload" id="async-upload" />
- <?php submit_button( __( 'Upload' ), 'primary', 'html-upload', false ); ?>
+ <?php submit_button( _x( 'Upload', 'verb' ), 'primary', 'html-upload', false ); ?>
<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a>
</p>
<div class="clear"></div>
@@ -2845,38 +2850,37 @@
<div class="alignleft actions">
<?php
-
- $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";
-
- $arc_result = $wpdb->get_results( $arc_query );
-
- $month_count = count( $arc_result );
- $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0;
-
- if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
+ $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"
+ );
+
+ $month_count = count( $months );
+ $selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
+
+ if ( $month_count && ( 1 !== $month_count || 0 !== (int) $months[0]->month ) ) {
?>
<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
-
- foreach ( $arc_result as $arc_row ) {
- if ( 0 == $arc_row->yyear ) {
+ foreach ( $months as $arc_row ) {
+ if ( 0 === (int) $arc_row->year ) {
continue;
}
- $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
-
- if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) {
- $default = ' selected="selected"';
- } else {
- $default = '';
- }
-
- 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";
+ $month = zeroise( $arc_row->month, 2 );
+ $year = $arc_row->year;
+
+ printf(
+ "<option %s value='%s'>%s</option>\n",
+ selected( $selected_month, $year . $month, false ),
+ 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 ) )
+ );
}
-
?>
</select>
<?php } ?>
@@ -3243,7 +3247,7 @@
__( '<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.' ),
/* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */
esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ),
- 'target="_blank" rel="noopener"',
+ 'target="_blank"',
sprintf(
'<span class="screen-reader-text"> %s</span>',
/* translators: Hidden accessibility text. */