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
This commit is contained in:
Andrew Ozz 2008-12-08 07:38:05 +00:00
parent a9d2fd15ff
commit d651a0c155
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;