Changeset 18932 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 10/10/2011 08:52:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r18833 r18932 2448 2448 } else { 2449 2449 // Default count updater 2450 foreach ( (array) $terms as $term) { 2451 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term) ); 2452 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 2453 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 2454 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 2455 } 2456 2450 _update_post_term_count( $terms, $taxonomy ); 2457 2451 } 2458 2452 … … 2847 2841 2848 2842 $object_types = is_array($taxonomy->object_type) ? $taxonomy->object_type : array($taxonomy->object_type); 2843 2844 foreach ( $object_types as &$object_type ) 2845 list( $object_type ) = explode( ':', $object_type ); 2846 2847 $object_types = array_unique( $object_types ); 2849 2848 $object_types = esc_sql($object_types); 2850 2849 2851 2850 foreach ( (array) $terms as $term ) { 2852 $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 ) ); 2851 2852 // Attachments can be 'inherit' status, we need to base count off the parent's staus if so 2853 if ( in_array( 'attachment', $object_types ) ) 2854 $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 ) ); 2855 else 2856 $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 ) ); 2857 2853 2858 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 2854 2859 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
Note: See TracChangeset
for help on using the changeset viewer.