Ticket #28381: unattached_attachments_patch.patch
File unattached_attachments_patch.patch, 1.6 KB (added by , 7 years ago) |
---|
-
wp-admin/includes/class-wp-media-list-table.php
47 47 $type_links = array(); 48 48 $_num_posts = (array) wp_count_attachments(); 49 49 $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 50 $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1");50 $total_orphans = wp_count_unattached_attachments(); 51 51 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 52 52 foreach ( $matches as $type => $reals ) 53 53 foreach ( $reals as $real ) -
wp-includes/post.php
2292 2292 } 2293 2293 2294 2294 /** 2295 * Count number of unattached attachments 2296 * 2297 * @since 4.0 2298 * 2299 * @return int The number of unattached attachments 2300 */ 2301 function wp_count_unattached_attachments() 2302 { 2303 global $wpdb; 2304 $unattached_attachments = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" ); 2305 2306 /** 2307 * Modify returned unattached attachment count 2308 * 2309 * @since 4.0 2310 * 2311 * @param int $unattached_attachments Number of unattached attachments 2312 */ 2313 return apply_filters( 'wp_count_unattached_attachments', (int) $unattached_attachments); 2314 } 2315 2316 /** 2295 2317 * Get default post mime types 2296 2318 * 2297 2319 * @since 2.9.0