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:
azaozz 2008-12-08 07:38:05 +00:00
parent 535b79426a
commit 5426f43c7d
1 changed files with 7 additions and 0 deletions

View File

@ -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;