Changeset 40425 for branches/4.7/src/wp-includes/media.php
- Timestamp:
- 04/14/2017 08:39:46 AM (7 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
- Property svn:mergeinfo changed
/trunk merged: 40382,40421
- Property svn:mergeinfo changed
-
branches/4.7/src/wp-includes/media.php
r40071 r40425 3320 3320 } 3321 3321 3322 $has_audio = $wpdb->get_var( " 3323 SELECT ID 3324 FROM $wpdb->posts 3325 WHERE post_type = 'attachment' 3326 AND post_mime_type LIKE 'audio%' 3327 LIMIT 1 3328 " ); 3329 $has_video = $wpdb->get_var( " 3330 SELECT ID 3331 FROM $wpdb->posts 3332 WHERE post_type = 'attachment' 3333 AND post_mime_type LIKE 'video%' 3334 LIMIT 1 3335 " ); 3336 $months = $wpdb->get_results( $wpdb->prepare( " 3337 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 3338 FROM $wpdb->posts 3339 WHERE post_type = %s 3340 ORDER BY post_date DESC 3341 ", 'attachment' ) ); 3322 /** 3323 * Allows showing or hiding the "Create Audio Playlist" button in the media library. 3324 * 3325 * By default (if this filter returns `null`), a query will be run to 3326 * determine whether the media library contains any audio items. This 3327 * query is expensive for large media libraries, so it may be desirable for 3328 * sites to override this behavior. 3329 * 3330 * @since 4.7.4 3331 * 3332 * @link https://core.trac.wordpress.org/ticket/31071 3333 * 3334 * @param bool|null Whether to show the button, or `null` for default behavior. 3335 */ 3336 $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', null ); 3337 if ( null === $show_audio_playlist ) { 3338 $show_audio_playlist = $wpdb->get_var( " 3339 SELECT ID 3340 FROM $wpdb->posts 3341 WHERE post_type = 'attachment' 3342 AND post_mime_type LIKE 'audio%' 3343 LIMIT 1 3344 " ); 3345 } 3346 3347 /** 3348 * Allows showing or hiding the "Create Video Playlist" button in the media library. 3349 * 3350 * By default (if this filter returns `null`), a query will be run to 3351 * determine whether the media library contains any video items. This 3352 * query is expensive for large media libraries, so it may be desirable for 3353 * sites to override this behavior. 3354 * 3355 * @since 4.7.4 3356 * 3357 * @link https://core.trac.wordpress.org/ticket/31071 3358 * 3359 * @param bool|null Whether to show the button, or `null` for default behavior. 3360 */ 3361 $show_video_playlist = apply_filters( 'media_library_show_video_playlist', null ); 3362 if ( null === $show_video_playlist ) { 3363 $show_video_playlist = $wpdb->get_var( " 3364 SELECT ID 3365 FROM $wpdb->posts 3366 WHERE post_type = 'attachment' 3367 AND post_mime_type LIKE 'video%' 3368 LIMIT 1 3369 " ); 3370 } 3371 3372 /** 3373 * Allows overriding the list of months displayed in the media library. 3374 * 3375 * By default (if this filter does not return an array), a query will be 3376 * run to determine the months that have media items. This query can be 3377 * expensive for large media libraries, so it may be desirable for sites to 3378 * override this behavior. 3379 * 3380 * @since 4.7.4 3381 * 3382 * @link https://core.trac.wordpress.org/ticket/31071 3383 * 3384 * @param array|null An array of objects with `month` and `year` 3385 * properties, or `null` (or any other non-array value) 3386 * for default behavior. 3387 */ 3388 $months = apply_filters( 'media_library_months_with_files', null ); 3389 if ( ! is_array( $months ) ) { 3390 $months = $wpdb->get_results( $wpdb->prepare( " 3391 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 3392 FROM $wpdb->posts 3393 WHERE post_type = %s 3394 ORDER BY post_date DESC 3395 ", 'attachment' ) ); 3396 } 3342 3397 foreach ( $months as $month_year ) { 3343 3398 $month_year->text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month_year->month ), $month_year->year ); … … 3358 3413 'defaultProps' => $props, 3359 3414 'attachmentCounts' => array( 3360 'audio' => ( $ has_audio) ? 1 : 0,3361 'video' => ( $ has_video ) ? 1 : 03415 'audio' => ( $show_audio_playlist ) ? 1 : 0, 3416 'video' => ( $show_video_playlist ) ? 1 : 0, 3362 3417 ), 3363 3418 'embedExts' => $exts, … … 3365 3420 'contentWidth' => $content_width, 3366 3421 'months' => $months, 3367 'mediaTrash' => MEDIA_TRASH ? 1 : 0 3422 'mediaTrash' => MEDIA_TRASH ? 1 : 0, 3368 3423 ); 3369 3424
Note: See TracChangeset
for help on using the changeset viewer.