Don't show trashed attachments in gallery tab count, props aldenta, fixes #11147

git-svn-id: http://svn.automattic.com/wordpress/trunk@12190 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-11-16 07:54:02 +00:00
parent 903ff7a22f
commit f53bef8bd9
1 changed files with 4 additions and 2 deletions

View File

@ -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']);