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
This commit is contained in:
Andrew Ozz 2009-11-16 07:54:02 +00:00
parent 3e1d80eb42
commit e085e3485e
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']);