Skip to content

Commit

Permalink
Media: Default to always showing the "Create Audio/Video Playlist" bu…
Browse files Browse the repository at this point in the history
…ttons.

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
  • Loading branch information
nylen committed Apr 14, 2017
1 parent 38c4565 commit 999c807
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 999c807

Please sign in to comment.