WordPress.org

Make WordPress Core

Ticket #12348: taxo.diff

File taxo.diff, 2.4 KB (added by momo360modena, 4 years ago)
  • wp-includes/taxonomy.php

     
    19101910 
    19111911        $taxonomy = get_taxonomy($taxonomy); 
    19121912        if ( !empty($taxonomy->update_count_callback) ) { 
    1913                 call_user_func($taxonomy->update_count_callback, $terms); 
     1913                call_user_func($taxonomy->update_count_callback, $terms, $taxonomy); 
    19141914        } else { 
    19151915                // Default count updater 
    19161916                foreach ( (array) $terms as $term) { 
    19171917                        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); 
    1918                         do_action( 'edit_term_taxonomy', $term ); 
     1918                        do_action( 'edit_term_taxonomy', $term, $taxonomy ); 
    19191919                        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 
    1920                         do_action( 'edited_term_taxonomy', $term ); 
     1920                        do_action( 'edited_term_taxonomy', $term, $taxonomy ); 
    19211921                } 
    19221922 
    19231923        } 
     
    22922292// 
    22932293 
    22942294/** 
    2295  * Will update term count based on posts. 
     2295 * Will update term count based on object types of taxonomy. 
    22962296 * 
    22972297 * Private function for the default callback for post_tag and category 
    22982298 * taxonomies. 
     
    23042304 * @uses $wpdb 
    23052305 * 
    23062306 * @param array $terms List of Term taxonomy IDs 
     2307 * @param object $taxonomy current taxonomy of terms 
    23072308 */ 
    2308 function _update_post_term_count( $terms ) { 
     2309function _update_post_term_count( $terms, $taxonomy ) { 
    23092310        global $wpdb; 
     2311         
     2312        if( !is_array($taxonomy->object_type) ) 
     2313                $taxonomy->object_type = array($taxonomy->object_type); 
    23102314 
    23112315        foreach ( (array) $terms as $term ) { 
    2312                 $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 = 'post' AND term_taxonomy_id = %d", $term ) ); 
    2313                 do_action( 'edit_term_taxonomy', $term ); 
     2316                $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("', '", $taxonomy->object_type)."') AND term_taxonomy_id = %d", $term ) ); 
     2317                do_action( 'edit_term_taxonomy', $term, $taxonomy ); 
    23142318                $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 
    2315                 do_action( 'edited_term_taxonomy', $term ); 
     2319                do_action( 'edited_term_taxonomy', $term, $taxonomy ); 
    23162320        } 
    23172321} 
    23182322