WordPress.org

Make WordPress Core

Changeset 40430


Ignore:
Timestamp:
04/14/2017 11:25:00 AM (14 months ago)
Author:
jnylen0
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r40421 r40430  
    33253325     * Allows showing or hiding the "Create Audio Playlist" button in the media library.
    33263326     *
    3327      * By default (if this filter returns `null`), a query will be run to
    3328      * determine whether the media library contains any audio items.  This
    3329      * query is expensive for large media libraries, so it may be desirable for
    3330      * sites to override this behavior.
     3327     * By default, the "Create Audio Playlist" button will always be shown in
     3328     * the media library.  If this filter returns `null`, a query will be run
     3329     * to determine whether the media library contains any audio items.  This
     3330     * was the default behavior prior to version 4.8.0, but this query is
     3331     * expensive for large media libraries.
    33313332     *
    33323333     * @since 4.7.4
     3334     * @since 4.8.0 The filter's default value is `true` rather than `null`.
    33333335     *
    33343336     * @link https://core.trac.wordpress.org/ticket/31071
    33353337     *
    3336      * @param bool|null Whether to show the button, or `null` for default behavior.
    3337      */
    3338     $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', null );
     3338     * @param bool|null Whether to show the button, or `null` to decide based
     3339     *                  on whether any audio files exist in the media library.
     3340     */
     3341    $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
    33393342    if ( null === $show_audio_playlist ) {
    33403343        $show_audio_playlist = $wpdb->get_var( "
     
    33503353     * Allows showing or hiding the "Create Video Playlist" button in the media library.
    33513354     *
    3352      * By default (if this filter returns `null`), a query will be run to
    3353      * determine whether the media library contains any video items.  This
    3354      * query is expensive for large media libraries, so it may be desirable for
    3355      * sites to override this behavior.
     3355     * By default, the "Create Video Playlist" button will always be shown in
     3356     * the media library.  If this filter returns `null`, a query will be run
     3357     * to determine whether the media library contains any video items.  This
     3358     * was the default behavior prior to version 4.8.0, but this query is
     3359     * expensive for large media libraries.
    33563360     *
    33573361     * @since 4.7.4
     3362     * @since 4.8.0 The filter's default value is `true` rather than `null`.
    33583363     *
    33593364     * @link https://core.trac.wordpress.org/ticket/31071
    33603365     *
    3361      * @param bool|null Whether to show the button, or `null` for default behavior.
    3362      */
    3363     $show_video_playlist = apply_filters( 'media_library_show_video_playlist', null );
     3366     * @param bool|null Whether to show the button, or `null` to decide based
     3367     *                  on whether any video files exist in the media library.
     3368     */
     3369    $show_video_playlist = apply_filters( 'media_library_show_video_playlist', true );
    33643370    if ( null === $show_video_playlist ) {
    33653371        $show_video_playlist = $wpdb->get_var( "
Note: See TracChangeset for help on using the changeset viewer.