I am adding a new way to upload a media file to WordPress. So I am looking for a way to add a link or a button to the Upload New Media page.
What is the recommended filter? Or is there another better solution to add a button?
Here is a screenshot of what I am trying to accomplish:
I added a button named: “Other Option”.
I also added: “Another option: Other Option”. On top of Maximum upload file size…
Edited after OP insert edited question
Once you are creating a new upload system, I thing that you want to add button/link to different part of WP admin:
First 2 are pretty easy, thatnk to, respectively,
add_media_page
and$wp_admin_bar->add_node
functions.The third, is a bit hard to obtain, because thta button is hardcoded in core, it can be added via javascript, but in core there is an hook,
'post-plupload-upload-ui'
, that allow to output something after the dragging area, I think it can be good as well for your scope (see screenshot at bottom of this answer).The fourth is the more hard to obtain, because there is no hook for that, however, just before the output of deafult “Add New” button, in the code there’s this line:
where
$title
is__('Media Library')
.The value returned by
esc_html
can be changed using theesc_html
filter, so you can use this filter to output the markup of your custom buttom. However you should pay attention to run the filter only on proper page, only for the wanted string and remove it after first run: otherwise any string passed toesc_html
will be affected.Note that is a tricky way, so in future versions of WP it can’t work anymore, but with current version (3.8) and previous (3.1 and newer) it works.
I created a class, that handle all the 4 tasks. The class is posted here as a standalone plugin, but probably it will be usefull to be integrated in your plugin.
Of course you have to customize the first 3 functions.
Screenshots
In the Media page
In the Media > Add New Page
New Submenu of Media Menu
New Submenu of “+ New” Menu in Admin Bar