The media_view_strings filter hook is for the text strings. I think there are other hooks you need to target.
I believe the following should disable the audio and video playlists (I’m not sure about galleries yet):
add_action( 'init', function() {
if ( ! current_user_can( 'manage_options' ) ) {
add_filter( 'media_library_show_audio_playlist', '__return_false' );
add_filter( 'media_library_show_video_playlist', '__return_false' );
}
} );
I’m just poking around the filter hooks in this function: https://developer.ww.wp.xz.cn/reference/functions/wp_enqueue_media/
Thanks Justin, unfortunately those didn’t seem to work 🙁
Curiously, the filters do what they are supposed to do, set media counts to zero. At some time in the past I think a zero count would suppress the associated playlist links. But since one may want to upload new media into a playlist, that behavior doesn’t make sense. I speculate the behavior was subsequently modified, which in turn made the filter’s purpose fail to work as intended.
I don’t have a solution, I just wanted to report what little more I found out. I think we need to find the code that actually outputs the links in order to find a way to suppress the links.
I’ve another idea though. Could you simply hide the links with CSS? You could conditionally output some inline CSS from the “admin_print_styles” action. Hook with a very large priority arg so the styles are output after all others. If a user happened to know the proper URL, they could still create a playlist, but the lack of a link will deter nearly everyone.
Thanks, so would this be something like:
function remove_media_links(){ ?>
<style>
.media-frame-menu {display: none;}
</style>
<?php }
add_action('admin_print_styles','remove_media_links');
Yeah, that’s the idea. Did you really want to hide all links? If so, you may want to hide the “Actions” title as well. Looks weird in an otherwise empty side panel 🙂
Wouldn’t you still want to manage style output with a ! current_user_can( 'manage_options' ) conditional so mods can still easily access the links?
I’d add a , 9999 parameter to the add_action() call to help ensure the style is output after all others.