From e085e3485e80883b81bc0772c345fb158e7e9907 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 16 Nov 2009 07:54:02 +0000 Subject: [PATCH] Don't show trashed attachments in gallery tab count, props aldenta, fixes #11147 git-svn-id: https://develop.svn.wordpress.org/trunk@12190 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 9112343408..7914b0cb89 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -40,8 +40,10 @@ function update_gallery_tab($tabs) { 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']))); + $post_id = intval($_REQUEST['post_id']); + + if ( $post_id ) + $attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) ); if ( empty($attachments) ) { unset($tabs['gallery']);