Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: update_term_count

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
4194           /**
4195            * Fires when a term count is calculated, before it is updated in the database.
4196            *
4197            * @since 6.9.0
4198            *
4199            * @param int    $tt_id         Term taxonomy ID.
4200            * @param string $taxonomy_name Taxonomy slug.
4201            * @param int    $count         Term count.
4202            */
4203           do_action( 'update_term_count', $tt_id, $taxonomy->name, $count );
4204
4205           /** This action is documented in wp-includes/taxonomy.php */
4206           do_action( 'edit_term_taxonomy', $tt_id, $taxonomy->name );
4207           $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $tt_id ) );
4208
4209           /** This action is documented in wp-includes/taxonomy.php */
4210           do_action( 'edited_term_taxonomy', $tt_id, $taxonomy->name );
4211      }
4212 }
 
Line Code
4224  * @param WP_Taxonomy $taxonomy Current taxonomy object of terms.
4225  */
4226 function _update_generic_term_count( $terms, $taxonomy ) {
4227      global $wpdb;
4228
4229      foreach ( (array) $terms as $term ) {
4230           $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
4231
4232           /** This action is documented in wp-includes/taxonomy.php */
4233           do_action( 'update_term_count', $term, $taxonomy->name, $count );
4234
4235           /** This action is documented in wp-includes/taxonomy.php */
4236           do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
4237           $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
4238
4239           /** This action is documented in wp-includes/taxonomy.php */
4240           do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
4241      }
4242 }