Do not show Gallery tab in the uploader if no files have been uploaded.
git-svn-id: http://svn.automattic.com/wordpress/trunk@10124 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
535b79426a
commit
5426f43c7d
|
@ -34,13 +34,20 @@ function media_upload_tabs() {
|
|||
*/
|
||||
function update_gallery_tab($tabs) {
|
||||
global $wpdb;
|
||||
|
||||
if ( !isset($_REQUEST['post_id']) ) {
|
||||
unset($tabs['gallery']);
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
if ( intval($_REQUEST['post_id']) )
|
||||
$attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])));
|
||||
|
||||
if ( empty($attachments) ) {
|
||||
unset($tabs['gallery']);
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
|
||||
|
||||
return $tabs;
|
||||
|
|
Loading…
Reference in New Issue