From 7d8451ff70a528233791dcc78c780b016cbeb247 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Thu, 13 Apr 2017 20:22:44 +0000 Subject: [PATCH] Media: Improve filters that allow overriding slow media queries. As a follow-up to [40382], this commit makes the following improvements: - Make the filter names more specific. - Fix the inline documentation (use `@param` instead of `@return). - Use `null ===` instead of `is_null` to avoid extra function calls. - Rename the `$has_audio` and `$has_video` variables now that they actually represent something slightly different. See #31071. Built from https://develop.svn.wordpress.org/trunk@40421 git-svn-id: http://core.svn.wordpress.org/trunk@40319 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 30 +++++++++++++++--------------- wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 195d0f9c7d..d3ba104454 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3333,11 +3333,11 @@ function wp_enqueue_media( $args = array() ) { * * @link https://core.trac.wordpress.org/ticket/31071 * - * @return bool|null Whether to show the button, or `null` for default behavior. + * @param bool|null Whether to show the button, or `null` for default behavior. */ - $has_audio = apply_filters( 'media_has_audio', null ); - if ( is_null( $has_audio ) ) { - $has_audio = $wpdb->get_var( " + $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', null ); + if ( null === $show_audio_playlist ) { + $show_audio_playlist = $wpdb->get_var( " SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' @@ -3358,11 +3358,11 @@ function wp_enqueue_media( $args = array() ) { * * @link https://core.trac.wordpress.org/ticket/31071 * - * @return bool|null Whether to show the button, or `null` for default behavior. + * @param bool|null Whether to show the button, or `null` for default behavior. */ - $has_video = apply_filters( 'media_has_video', null ); - if ( is_null( $has_video ) ) { - $has_video = $wpdb->get_var( " + $show_video_playlist = apply_filters( 'media_library_show_video_playlist', null ); + if ( null === $show_video_playlist ) { + $show_video_playlist = $wpdb->get_var( " SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' @@ -3383,11 +3383,11 @@ function wp_enqueue_media( $args = array() ) { * * @link https://core.trac.wordpress.org/ticket/31071 * - * @return array|null An array of objects with `month` and `year` - * properties, or `null` (or any other non-array value) - * for default behavior. + * @param array|null An array of objects with `month` and `year` + * properties, or `null` (or any other non-array value) + * for default behavior. */ - $months = apply_filters( 'media_months', null ); + $months = apply_filters( 'media_library_months_with_files', null ); if ( ! is_array( $months ) ) { $months = $wpdb->get_results( $wpdb->prepare( " SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month @@ -3414,14 +3414,14 @@ function wp_enqueue_media( $args = array() ) { ), 'defaultProps' => $props, 'attachmentCounts' => array( - 'audio' => ( $has_audio ) ? 1 : 0, - 'video' => ( $has_video ) ? 1 : 0 + 'audio' => ( $show_audio_playlist ) ? 1 : 0, + 'video' => ( $show_video_playlist ) ? 1 : 0, ), 'embedExts' => $exts, 'embedMimes' => $ext_mimes, 'contentWidth' => $content_width, 'months' => $months, - 'mediaTrash' => MEDIA_TRASH ? 1 : 0 + 'mediaTrash' => MEDIA_TRASH ? 1 : 0, ); $post = null; diff --git a/wp-includes/version.php b/wp-includes/version.php index 54b1560e53..162c42d314 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40418'; +$wp_version = '4.8-alpha-40421'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.