From 999c807b8844177ca8c18c943fcdc12c1a83e898 Mon Sep 17 00:00:00 2001 From: James Nylen Date: Fri, 14 Apr 2017 11:25:43 +0000 Subject: [PATCH] Media: Default to always showing the "Create Audio/Video Playlist" buttons. This avoids a couple of expensive queries that attempt to determine whether the media library contains any audio or video items, and also makes the UI for creating playlists more discoverable. [40382] and [40421] added filters to allow overriding this behavior; this commit changes the default value of the filters to always show these UI buttons and never run the expensive queries. The old behavior can still be restored using the filters if desired. Props sboisvert, adamsilverstein, joemcgill, jnylen0. Fixes #31071. Built from https://develop.svn.wordpress.org/trunk@40430 git-svn-id: http://core.svn.wordpress.org/trunk@40328 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 30 ++++++++++++++++++------------ wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index d3ba104454..6253bd5742 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3324,18 +3324,21 @@ function wp_enqueue_media( $args = array() ) { /** * Allows showing or hiding the "Create Audio Playlist" button in the media library. * - * By default (if this filter returns `null`), a query will be run to - * determine whether the media library contains any audio items. This - * query is expensive for large media libraries, so it may be desirable for - * sites to override this behavior. + * By default, the "Create Audio Playlist" button will always be shown in + * the media library. If this filter returns `null`, a query will be run + * to determine whether the media library contains any audio items. This + * was the default behavior prior to version 4.8.0, but this query is + * expensive for large media libraries. * * @since 4.7.4 + * @since 4.8.0 The filter's default value is `true` rather than `null`. * * @link https://core.trac.wordpress.org/ticket/31071 * - * @param bool|null Whether to show the button, or `null` for default behavior. + * @param bool|null Whether to show the button, or `null` to decide based + * on whether any audio files exist in the media library. */ - $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', null ); + $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true ); if ( null === $show_audio_playlist ) { $show_audio_playlist = $wpdb->get_var( " SELECT ID @@ -3349,18 +3352,21 @@ function wp_enqueue_media( $args = array() ) { /** * Allows showing or hiding the "Create Video Playlist" button in the media library. * - * By default (if this filter returns `null`), a query will be run to - * determine whether the media library contains any video items. This - * query is expensive for large media libraries, so it may be desirable for - * sites to override this behavior. + * By default, the "Create Video Playlist" button will always be shown in + * the media library. If this filter returns `null`, a query will be run + * to determine whether the media library contains any video items. This + * was the default behavior prior to version 4.8.0, but this query is + * expensive for large media libraries. * * @since 4.7.4 + * @since 4.8.0 The filter's default value is `true` rather than `null`. * * @link https://core.trac.wordpress.org/ticket/31071 * - * @param bool|null Whether to show the button, or `null` for default behavior. + * @param bool|null Whether to show the button, or `null` to decide based + * on whether any video files exist in the media library. */ - $show_video_playlist = apply_filters( 'media_library_show_video_playlist', null ); + $show_video_playlist = apply_filters( 'media_library_show_video_playlist', true ); if ( null === $show_video_playlist ) { $show_video_playlist = $wpdb->get_var( " SELECT ID diff --git a/wp-includes/version.php b/wp-includes/version.php index aa74f6fd88..74fd485d29 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40428'; +$wp_version = '4.8-alpha-40430'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.