media_library_show_audio_playlist
Filter HookDescription
Allows showing or hiding the "Create Audio Playlist" button in the media library. 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.Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4820 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool|null
|
$show
|
Whether to show the button, or `null` to decide based on whether any audio files exist in the media library. |
Usage Examples
Basic Usage
<?php
// Hook into media_library_show_audio_playlist
add_filter('media_library_show_audio_playlist', 'my_custom_filter', 10, 1);
function my_custom_filter($show) {
// Your custom filtering logic here
return $show;
}
Source Code Context
wp-includes/media.php:4820
- How this hook is used in WordPress core
<?php
4815 * @link https://core.trac.wordpress.org/ticket/31071
4816 *
4817 * @param bool|null $show Whether to show the button, or `null` to decide based
4818 * on whether any audio files exist in the media library.
4819 */
4820 $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
4821 if ( null === $show_audio_playlist ) {
4822 $show_audio_playlist = $wpdb->get_var(
4823 "SELECT ID
4824 FROM $wpdb->posts
4825 WHERE post_type = 'attachment'
PHP Documentation
<?php
/**
* Allows showing or hiding the "Create Audio Playlist" button in the media library.
*
* 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 $show Whether to show the button, or `null` to decide based
* on whether any audio files exist in the media library.
*/
Quick Info
- Hook Type: Filter
- Parameters: 1
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.