WordPress.org

Make WordPress Core

Ticket #10620: 10620.patch

File 10620.patch, 1.3 KB (added by hakre, 6 years ago)
  • wp-admin/includes/media.php

     
    4141        } 
    4242 
    4343        if ( intval($_REQUEST['post_id']) ) 
    44                 $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); 
     44                $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $_REQUEST['post_id']))); 
    4545 
    4646        if ( empty($attachments) ) { 
    4747                unset($tabs['gallery']); 
     
    10541054                if ( $post && $post->post_type == 'attachment' ) 
    10551055                        $attachments = array($post->ID => $post); 
    10561056                else 
    1057                         $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); 
     1057                        $attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_status' => 'inherit', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); 
    10581058        } else { 
    10591059                if ( is_array($GLOBALS['wp_the_query']->posts) ) 
    10601060                        foreach ( $GLOBALS['wp_the_query']->posts as $attachment )