Ticket #12348: taxo.diff
| File taxo.diff, 2.4 KB (added by , 16 years ago) |
|---|
-
wp-includes/taxonomy.php
1910 1910 1911 1911 $taxonomy = get_taxonomy($taxonomy); 1912 1912 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); 1914 1914 } else { 1915 1915 // Default count updater 1916 1916 foreach ( (array) $terms as $term) { 1917 1917 $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 ); 1919 1919 $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 ); 1921 1921 } 1922 1922 1923 1923 } … … 2292 2292 // 2293 2293 2294 2294 /** 2295 * Will update term count based on posts.2295 * Will update term count based on object types of taxonomy. 2296 2296 * 2297 2297 * Private function for the default callback for post_tag and category 2298 2298 * taxonomies. … … 2304 2304 * @uses $wpdb 2305 2305 * 2306 2306 * @param array $terms List of Term taxonomy IDs 2307 * @param object $taxonomy current taxonomy of terms 2307 2308 */ 2308 function _update_post_term_count( $terms ) {2309 function _update_post_term_count( $terms, $taxonomy ) { 2309 2310 global $wpdb; 2311 2312 if( !is_array($taxonomy->object_type) ) 2313 $taxonomy->object_type = array($taxonomy->object_type); 2310 2314 2311 2315 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 ); 2314 2318 $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 ); 2316 2320 } 2317 2321 } 2318 2322