From d651a0c155dc6dc3c0affd1300b267432179fe78 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 8 Dec 2008 07:38:05 +0000 Subject: [PATCH] Do not show Gallery tab in the uploader if no files have been uploaded. git-svn-id: https://develop.svn.wordpress.org/trunk@10124 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index eb95bc852d..7ea8247b76 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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)'), "$attachments"); return $tabs;