[wp-trac] [WordPress Trac] #22925: media_upload_tabs filter not functioning

WordPress Trac noreply at wordpress.org
Sat May 24 20:59:39 UTC 2014


#22925: media_upload_tabs filter not functioning
--------------------------+------------------------------
 Reporter:  kegster       |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  3.5
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by ericlewis):

 * keywords:  reporter-feedback =>
 * status:  new => closed
 * resolution:   => invalid


Comment:

 I can confirm media_upload_tabs still works for the old media modal.

 Boilerplate:

 {{{
 #!php
 <?php

 // Remove the URL tab
 add_filter( 'media_upload_tabs', function($tabs ) {
     unset( $tabs['type_url'] );
     return $tabs;
 } );

 /**
  * I WANT THE OLD UPLOADER BACK
  * All code by: A.Morita
  * URL: http://wordpress.org/support/topic/is-there-a-way-to-disable-the-
 new-media-manager/
  */

 /**
  * Old upload Thickbox
  */
 add_action( 'admin_head', 'remove_media_buttons' );

 function remove_media_buttons()
 {
     remove_action( 'media_buttons', 'media_buttons' );
     add_action( 'media_buttons', 'old_media_buttons' );
 }

 function old_media_buttons( $editor_id = 'content' )
 {
     $context = apply_filters( 'media_buttons_context', __('Upload/Insert
 %s') );

     $img = '<img src="'
         . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) )
         . '" width="15" height="15" />';

     echo '<a href="'
         . esc_url( get_upload_iframe_src() )
         . '" class="thickbox add_media" id="'
         . esc_attr( $editor_id )
         . '-add_media" title="'
         . esc_attr__( 'Add Media' )
         . '" onclick="return false;">'
         . sprintf( $context, $img )
         . '</a>';
 }

 /**
  * Featured image
  */
 add_action( 'wp_default_scripts', 'unset_media_views', 999, 1 );
 add_action( 'admin_head', 'remove_wp_print_media_templates' );

 function unset_media_views($scripts)
 {
     unset( $scripts->registered['media-views'] );
 }

 function remove_wp_print_media_templates()
 {
     remove_action( 'admin_footer', 'wp_print_media_templates' );
     remove_action( 'wp_footer', 'wp_print_media_templates' );
 }


 /**
  * Adjust Full Screen behavior
  */
 add_action( 'after_wp_tiny_mce', 'fullscreen_media_button' );

 function fullscreen_media_button()
 {
     ?>
     <script type="text/javascript">
     fullscreen.medialib = function()
     {
         var href = jQuery('div#wp-content-media-buttons
 a.thickbox').attr('href') || '';
         tb_show('', href);
     }
     </script>
     <?php
 }
 }}}

 Modifying the new tabs is a bit more tricky, keep an eye on my
 [https://github.com/ericandrewlewis/wp-media-backbone-guide Backbone media
 documentation plugin] for an example of that sometime soon.

 Closing out, feel free to reopen if there's more to it.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/22925#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list