WordPress.org

Make WordPress Core

Ticket #18986: 18986.3.patch

File 18986.3.patch, 2.6 KB (added by SergeyBiryukov, 3 years ago)
  • wp-includes/taxonomy.php

     
    28522852 
    28532853        foreach ( (array) $terms as $term ) { 
    28542854 
    2855                 // Attachments can be 'inherit' status, we need to base count off the parent's staus if so 
    2856                 if ( in_array( 'attachment', $object_types ) ) 
    2857                         $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) ); 
    2858                 else 
    2859                         $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) ); 
     2855                foreach ( $object_types as $object_type ) { 
     2856                        // Attachments can be 'inherit' status, we need to base count off the parent's staus if so 
     2857                        if ( 'attachment' == $object_type ) 
     2858                                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = %s AND term_taxonomy_id = %d", $object_type, $term ) ); 
     2859                        elseif ( post_type_exists( $object_type ) ) 
     2860                                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = %s AND term_taxonomy_id = %d", $object_type, $term ) ); 
     2861                        else 
     2862                                $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) ); 
    28602863 
    2861                 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 
    2862                 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 
    2863                 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 
     2864                        do_action( 'edit_term_taxonomy', $term, $taxonomy ); 
     2865                        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 
     2866                        do_action( 'edited_term_taxonomy', $term, $taxonomy ); 
     2867                } 
    28642868        } 
    28652869} 
    28662870