Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #18329


Ignore:
Timestamp:
08/04/2011 05:41:38 PM (13 years ago)
Author:
ocean90
Comment:

Code blocks added.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18329 – Description

    initial v1  
    1 wp-admin/includes/media.php has a default filter called update_gallery_tabs. The function unconditionally adds the $tabs['gallery'] back into $tabs if the post has image attachments. So if a user added a filter to remove the 'gallery' tab it will be added back if the post has images. You can get around this by making sure your filter runs after the default filter.
     1wp-admin/includes/media.php has a default filter called update_gallery_tabs. The function unconditionally adds {{{$tabs['gallery']}}} back into $tabs if the post has image attachments. So if a user added a filter to remove the 'gallery' tab it will be added back if the post has images. You can get around this by making sure your filter runs after the default filter.
    22
    33I think a saner behavior for any tab filter that does not expressly add a tab would be to check if the tab the filter is operation on is still present in $tabs.
    44
    5 I first wrapped the offending '$tabs['gallery'] = sprintf(__('Gallery (%s)'),' statement in a if statement but I think an initial 'if tab is not set return' makes for more readable code.
     5I first wrapped the offending {{{$tabs!['gallery'] = sprintf(!__('Gallery (%s)'),}}} statement in a if statement but I think an initial 'if tab is not set return' makes for more readable code.
    66
    77below is the code with the 'if tab is not set return' added:
    88
     9
     10{{{
    911function update_gallery_tab($tabs) {
    1012        global $wpdb;
     
    3436}
    3537add_filter('media_upload_tabs', 'update_gallery_tab')
     38}}}