771 |
771 |
772 if ( isset( $attachment['menu_order'] ) ) { |
772 if ( isset( $attachment['menu_order'] ) ) { |
773 $post['menu_order'] = $attachment['menu_order']; |
773 $post['menu_order'] = $attachment['menu_order']; |
774 } |
774 } |
775 |
775 |
776 if ( isset( $send_id ) && $attachment_id == $send_id ) { |
776 if ( isset( $send_id ) && $attachment_id === $send_id ) { |
777 if ( isset( $attachment['post_parent'] ) ) { |
777 if ( isset( $attachment['post_parent'] ) ) { |
778 $post['post_parent'] = $attachment['post_parent']; |
778 $post['post_parent'] = $attachment['post_parent']; |
779 } |
779 } |
780 } |
780 } |
781 |
781 |
1170 $output = array(); |
1170 $output = array(); |
1171 |
1171 |
1172 foreach ( $alignments as $name => $label ) { |
1172 foreach ( $alignments as $name => $label ) { |
1173 $name = esc_attr( $name ); |
1173 $name = esc_attr( $name ); |
1174 $output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" . |
1174 $output[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" . |
1175 ( $checked == $name ? " checked='checked'" : '' ) . |
1175 ( $checked === $name ? " checked='checked'" : '' ) . |
1176 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; |
1176 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; |
1177 } |
1177 } |
1178 |
1178 |
1179 return implode( "\n", $output ); |
1179 return implode( "\n", $output ); |
1180 } |
1180 } |
1220 // Is this size selectable? |
1220 // Is this size selectable? |
1221 $enabled = ( $downsize[3] || 'full' === $size ); |
1221 $enabled = ( $downsize[3] || 'full' === $size ); |
1222 $css_id = "image-size-{$size}-{$post->ID}"; |
1222 $css_id = "image-size-{$size}-{$post->ID}"; |
1223 |
1223 |
1224 // If this size is the default but that's not available, don't select it. |
1224 // If this size is the default but that's not available, don't select it. |
1225 if ( $size == $check ) { |
1225 if ( $size === $check ) { |
1226 if ( $enabled ) { |
1226 if ( $enabled ) { |
1227 $checked = " checked='checked'"; |
1227 $checked = " checked='checked'"; |
1228 } else { |
1228 } else { |
1229 $check = ''; |
1229 $check = ''; |
1230 } |
1230 } |
1760 } |
1760 } |
1761 |
1761 |
1762 if ( 'image' === $type && $calling_post_id |
1762 if ( 'image' === $type && $calling_post_id |
1763 && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) |
1763 && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) |
1764 && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) |
1764 && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) |
1765 && get_post_thumbnail_id( $calling_post_id ) != $attachment_id |
1765 && get_post_thumbnail_id( $calling_post_id ) !== $attachment_id |
1766 ) { |
1766 ) { |
1767 |
1767 |
1768 $calling_post = get_post( $calling_post_id ); |
1768 $calling_post = get_post( $calling_post_id ); |
1769 $calling_post_type_object = get_post_type_object( $calling_post->post_type ); |
1769 $calling_post_type_object = get_post_type_object( $calling_post->post_type ); |
1770 |
1770 |
2192 str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) |
2192 str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) |
2193 ) { |
2193 ) { |
2194 $plupload_init['multi_selection'] = false; |
2194 $plupload_init['multi_selection'] = false; |
2195 } |
2195 } |
2196 |
2196 |
2197 // Check if WebP images can be edited. |
2197 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */ |
2198 if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { |
2198 $prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, null ); |
2199 $plupload_init['webp_upload_error'] = true; |
2199 |
2200 } |
2200 if ( $prevent_unsupported_uploads ) { |
2201 |
2201 // Check if WebP images can be edited. |
2202 // Check if AVIF images can be edited. |
2202 if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { |
2203 if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) { |
2203 $plupload_init['webp_upload_error'] = true; |
2204 $plupload_init['avif_upload_error'] = true; |
2204 } |
|
2205 |
|
2206 // Check if AVIF images can be edited. |
|
2207 if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) { |
|
2208 $plupload_init['avif_upload_error'] = true; |
|
2209 } |
2205 } |
2210 } |
2206 |
2211 |
2207 /** |
2212 /** |
2208 * Filters the default Plupload settings. |
2213 * Filters the default Plupload settings. |
2209 * |
2214 * |
2275 ?> |
2280 ?> |
2276 <p id="async-upload-wrap"> |
2281 <p id="async-upload-wrap"> |
2277 <label class="screen-reader-text" for="async-upload"> |
2282 <label class="screen-reader-text" for="async-upload"> |
2278 <?php |
2283 <?php |
2279 /* translators: Hidden accessibility text. */ |
2284 /* translators: Hidden accessibility text. */ |
2280 _e( 'Upload' ); |
2285 _ex( 'Upload', 'verb' ); |
2281 ?> |
2286 ?> |
2282 </label> |
2287 </label> |
2283 <input type="file" name="async-upload" id="async-upload" /> |
2288 <input type="file" name="async-upload" id="async-upload" /> |
2284 <?php submit_button( __( 'Upload' ), 'primary', 'html-upload', false ); ?> |
2289 <?php submit_button( _x( 'Upload', 'verb' ), 'primary', 'html-upload', false ); ?> |
2285 <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a> |
2290 <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e( 'Cancel' ); ?></a> |
2286 </p> |
2291 </p> |
2287 <div class="clear"></div> |
2292 <div class="clear"></div> |
2288 <?php |
2293 <?php |
2289 /** |
2294 /** |
2843 } |
2848 } |
2844 ?> |
2849 ?> |
2845 |
2850 |
2846 <div class="alignleft actions"> |
2851 <div class="alignleft actions"> |
2847 <?php |
2852 <?php |
2848 |
2853 $months = $wpdb->get_results( |
2849 $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"; |
2854 "SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
2850 |
2855 FROM $wpdb->posts |
2851 $arc_result = $wpdb->get_results( $arc_query ); |
2856 WHERE post_type = 'attachment' |
2852 |
2857 ORDER BY post_date DESC" |
2853 $month_count = count( $arc_result ); |
2858 ); |
2854 $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; |
2859 |
2855 |
2860 $month_count = count( $months ); |
2856 if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { |
2861 $selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
|
2862 |
|
2863 if ( $month_count && ( 1 !== $month_count || 0 !== (int) $months[0]->month ) ) { |
2857 ?> |
2864 ?> |
2858 <select name='m'> |
2865 <select name='m'> |
2859 <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> |
2866 <option<?php selected( $selected_month, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option> |
2860 <?php |
2867 <?php |
2861 |
2868 foreach ( $months as $arc_row ) { |
2862 foreach ( $arc_result as $arc_row ) { |
2869 if ( 0 === (int) $arc_row->year ) { |
2863 if ( 0 == $arc_row->yyear ) { |
|
2864 continue; |
2870 continue; |
2865 } |
2871 } |
2866 |
2872 |
2867 $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
2873 $month = zeroise( $arc_row->month, 2 ); |
2868 |
2874 $year = $arc_row->year; |
2869 if ( $arc_row->yyear . $arc_row->mmonth == $selected_month ) { |
2875 |
2870 $default = ' selected="selected"'; |
2876 printf( |
2871 } else { |
2877 "<option %s value='%s'>%s</option>\n", |
2872 $default = ''; |
2878 selected( $selected_month, $year . $month, false ), |
2873 } |
2879 esc_attr( $year . $month ), |
2874 |
2880 /* translators: 1: Month name, 2: 4-digit year. */ |
2875 echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; |
2881 esc_html( sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) ) |
2876 echo esc_html( $wp_locale->get_month( $arc_row->mmonth ) . " $arc_row->yyear" ); |
2882 ); |
2877 echo "</option>\n"; |
2883 } |
2878 } |
|
2879 |
|
2880 ?> |
2884 ?> |
2881 </select> |
2885 </select> |
2882 <?php } ?> |
2886 <?php } ?> |
2883 |
2887 |
2884 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?> |
2888 <?php submit_button( __( 'Filter »' ), '', 'post-query-submit', false ); ?> |
3241 printf( |
3245 printf( |
3242 /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */ |
3246 /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */ |
3243 __( '<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.' ), |
3247 __( '<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.' ), |
3244 /* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */ |
3248 /* translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations. */ |
3245 esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ), |
3249 esc_url( __( 'https://www.w3.org/WAI/tutorials/images/decision-tree/' ) ), |
3246 'target="_blank" rel="noopener"', |
3250 'target="_blank"', |
3247 sprintf( |
3251 sprintf( |
3248 '<span class="screen-reader-text"> %s</span>', |
3252 '<span class="screen-reader-text"> %s</span>', |
3249 /* translators: Hidden accessibility text. */ |
3253 /* translators: Hidden accessibility text. */ |
3250 __( '(opens in a new tab)' ) |
3254 __( '(opens in a new tab)' ) |
3251 ) |
3255 ) |