I want to add a simple button to the Media Library top menu (say, to the right of the bulk actions / filters dropdowns. I have scoured the WordPress codex for a proper way to do this and have found nothing useful.
So before I start attacking this problem with Javascript, I wanted to ask the community if there’s a proper WordPress API way of doing this – along the lines of
manage_media_columns
and manage_media_custom_column
.
Thanks everyone!
So, this is the only way I’ve found so far and it’s ugly, however WordPress offers no means of modifying this through filters that I can find in core. I present, the hacky “do-it-through-Javascript” method:
Obviously, you should be enqueuing the Javascript you want instead of doing it like I am, but this is a proof-of-concept. It will add a button to both Media Library toolbars (list view and gallery view).
The reason for the
setTimeout
is that the filter bars actually load after page load, so waiting on document ready is not enough. There’s probably a better place to hook this in, but this should be a good start.