The function media_upload_tabs()
is not deprecated. It is called only by the_media_upload_tabs()
(perfect naming, I know), which as well is only called once by media_upload_header()
...
Edit - Just tested the filter with a plugin and while it's working and a var_dump( $tabs )
in an attached callback spits out the tabs, it doesn't do anything. The reason seems to be that all this now is generated by backbone and underscore templates with JavaScript. The file responsible for all the templates is ~/wp-includes/media-template.php
. From a search through that, there's no filter to alter the output. Basically it's just one massive PHP function named wp_print_media_templates()
that wraps all the templates and that has some actions before and after different templates.
I just tried to console.log()
the wp
object and found wp.media.view
which seems to hold ... something. ~/wp-includes/js/media-modals.js
seems to be the root of all that JavaScript generated UI. Now when I dig deeper, I find wp.template
that gets "underscore-extend
ed" into wp.media.template
. Then I found the reference to ~/wp-includes/js/wp-util.js
which then explains, that the argument for that JS function is an #id
that is prefixed by tmpl-
.
Now that only is a wrapper for _.memoize()
which adds a custom callback "saves" computed results to "speed things up"... a bit. The contents are just a bunch of Regex-es that then get pushed to a function named compiled()
, which just is (again) a wrapper for
_.template( $( '#tmpl-' + id ).html(), null, options )
.. ok. There's as well stuff from ~/wp-includes/js/media-views.js
and ~/wp-includes/js/media-models.js
involved and as I know close to nothing about Backbone anymore, I got no clue how to proceed from there. I'll leave my debugging plugin for this answer as well as the answer as starting point for others here.
<?php
defined( 'ABSPATH' ) or exit;
/**
* Plugin Name: (#125669) Media Upload Tabs by role
* Description: Removes media upload tabs on a by-role base.
*/
add_action( 'admin_footer', 'wpse125669MediaUploadTabsRemove', 0 );
function wpse125669MediaUploadTabsRemove()
{
if ( "edit.php" !== get_current_screen()->parent_file )
return;
?>
<script type="text/javascript">
console.log( wp.media );
</script>
<?php
}