Changes between Initial Version and Version 1 of Ticket #18329
- Timestamp:
- 08/04/2011 05:41:38 PM (13 years ago)
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.1 wp-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. 2 2 3 3 I 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. 4 4 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.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. 6 6 7 7 below is the code with the 'if tab is not set return' added: 8 8 9 10 {{{ 9 11 function update_gallery_tab($tabs) { 10 12 global $wpdb; … … 34 36 } 35 37 add_filter('media_upload_tabs', 'update_gallery_tab') 38 }}}