Using WordPress ‘media_library_show_video_playlist’ PHP filter

The media_library_show_video_playlist WordPress PHP filter allows you to control the visibility of the “Create Video Playlist” button in the media library.

Usage

add_filter('media_library_show_video_playlist', 'your_custom_function');
function your_custom_function($show) {
  // your custom code here
  return $show;
}

Parameters

  • $show (bool|null): Whether to show the button, or null to decide based on whether any video files exist in the media library.

More information

See WordPress Developer Resources: media_library_show_video_playlist

Examples

Always show the “Create Video Playlist” button

This example ensures that the “Create Video Playlist” button is always visible.

add_filter('media_library_show_video_playlist', 'always_show_video_playlist');
function always_show_video_playlist($show) {
  return true;
}

Hide the “Create Video Playlist” button

This example hides the “Create Video Playlist” button.

add_filter('media_library_show_video_playlist', 'hide_video_playlist');
function hide_video_playlist($show) {
  return false;
}

Show the button only for admins

This example shows the “Create Video Playlist” button only for administrators.

add_filter('media_library_show_video_playlist', 'admin_show_video_playlist');
function admin_show_video_playlist($show) {
  if (current_user_can('manage_options')) {
    return true;
  }
  return false;
}

Show the button only when there are video files in the media library

This example shows the “Create Video Playlist” button only if there are video files in the media library.

add_filter('media_library_show_video_playlist', 'show_video_playlist_if_videos_exist');
function show_video_playlist_if_videos_exist($show) {
  return null;
}

Show the button only for users with a specific role

This example shows the “Create Video Playlist” button only for users with the “editor” role.

add_filter('media_library_show_video_playlist', 'editor_show_video_playlist');
function editor_show_video_playlist($show) {
  $user = wp_get_current_user();
  if (in_array('editor', $user->roles)) {
    return true;
  }
  return false;
}