Ticket #17019: 17019.3.diff
File 17019.3.diff, 3.7 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/class-wp-media-list-table.php
42 42 } 43 43 44 44 function get_views() { 45 global $ wpdb, $post_mime_types, $avail_post_mime_types;45 global $post_mime_types, $avail_post_mime_types; 46 46 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 51 $args = array( 52 'fields' => 'count', 53 'post_type' => 'attachment', 54 'post_status' => 'any', 55 'post_parent' => 0, 56 'suppress_filters' => false, 57 'query_context' => 'attachment_orphans_count', 58 ); 59 $total_orphans = (int) get_posts( $args ); 60 51 61 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 52 62 foreach ( $matches as $type => $reals ) 53 63 foreach ( $reals as $real ) … … 308 318 309 319 if ( $parent ) { 310 320 $title = _draft_or_post_title( $post->post_parent ); 311 $parent_type = get_post_type_object( $parent->post_type ); 321 $parent_type = get_post_type_object( $parent->post_type ); 312 322 ?> 313 323 <td <?php echo $attributes ?>><strong> 314 324 <?php if ( current_user_can( 'edit_post', $post->post_parent ) && $parent_type->show_ui ) { ?> -
src/wp-admin/includes/media.php
33 33 * @return array $tabs with gallery if post has image attachment 34 34 */ 35 35 function update_gallery_tab($tabs) { 36 global $wpdb; 37 38 if ( !isset($_REQUEST['post_id']) ) { 39 unset($tabs['gallery']); 36 if ( ! isset( $_REQUEST['post_id'] ) ) { 37 unset( $tabs['gallery'] ); 40 38 return $tabs; 41 39 } 42 40 43 $post_id = intval( $_REQUEST['post_id']);41 $post_id = intval( $_REQUEST['post_id'] ); 44 42 45 if ( $post_id ) 46 $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 ) ) ); 43 if ( $post_id ) { 44 $args = array( 45 'fields' => 'count', 46 'post_type' => 'attachment', 47 'post_status' => 'any', 48 'post_parent' => $post_id, 49 'suppress_filters' => false, 50 'query_context' => 'gallery_attachment_count', 51 ); 52 $attachments = (int) get_posts( $args ); 53 } 47 54 48 if ( empty( $attachments) ) {49 unset( $tabs['gallery']);55 if ( empty( $attachments ) ) { 56 unset( $tabs['gallery'] ); 50 57 return $tabs; 51 58 } 52 59 -
src/wp-includes/query.php
1409 1409 , 'sentence' 1410 1410 , 'fields' 1411 1411 , 'menu_order' 1412 , 'query_context' 1412 1413 ); 1413 1414 1414 1415 foreach ( $keys as $key ) { … … 2069 2070 case 'id=>parent': 2070 2071 $fields = "$wpdb->posts.ID, $wpdb->posts.post_parent"; 2071 2072 break; 2073 case 'count': 2074 $fields = "COUNT(*)"; 2075 break; 2072 2076 default: 2073 2077 $fields = "$wpdb->posts.*"; 2074 2078 } … … 2717 2721 return $r; 2718 2722 } 2719 2723 2724 if ( 'count' == $q['fields'] ) { 2725 $this->posts = $wpdb->get_var( $this->request ); 2726 return $this->posts; 2727 } 2728 2720 2729 $split_the_query = ( $old_request == $this->request && "$wpdb->posts.*" == $fields && !empty( $limits ) && $q['posts_per_page'] < 500 ); 2721 2730 $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this ); 2722 2731