_update_generic_term_count

The timeline below displays how wordpress function _update_generic_term_count has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Updates term count based on number of objects.
 *
 * Default callback for the 'link_category' taxonomy.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int[]       $terms    List of term taxonomy IDs.
 * @param WP_Taxonomy $taxonomy Current taxonomy object of terms.
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy->name);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy->name);
    }
}

WordPress Version: 5.4

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the 'link_category' taxonomy.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int[]       $terms    List of term taxonomy IDs.
 * @param WP_Taxonomy $taxonomy Current taxonomy object of terms.
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy->name);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy->name);
    }
}

WordPress Version: 4.3

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the 'link_category' taxonomy.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array  $terms    List of term taxonomy IDs.
 * @param object $taxonomy Current taxonomy object of terms.
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy->name);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy->name);
    }
}

WordPress Version: 4.2

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the link_category taxonomy.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $terms List of Term taxonomy IDs
 * @param object $taxonomy Current taxonomy object of terms
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy->name);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy->name);
    }
}

WordPress Version: 4.1

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the link_category taxonomy.
 *
 * @since 3.3.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param array $terms List of Term taxonomy IDs
 * @param object $taxonomy Current taxonomy object of terms
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy);
    }
}

WordPress Version: 3.9

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the link_category taxonomy.
 *
 * @since 3.3.0
 * @uses $wpdb
 *
 * @param array $terms List of Term taxonomy IDs
 * @param object $taxonomy Current taxonomy object of terms
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edit_term_taxonomy', $term, $taxonomy);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        /** This action is documented in wp-includes/taxonomy.php */
        do_action('edited_term_taxonomy', $term, $taxonomy);
    }
}

WordPress Version: 3.7

/**
 * Will update term count based on number of objects.
 *
 * Default callback for the link_category taxonomy.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 3.3.0
 * @uses $wpdb
 *
 * @param array $terms List of Term taxonomy IDs
 * @param object $taxonomy Current taxonomy object of terms
 */
function _update_generic_term_count($terms, $taxonomy)
{
    global $wpdb;
    foreach ((array) $terms as $term) {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $term));
        do_action('edit_term_taxonomy', $term, $taxonomy);
        $wpdb->update($wpdb->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
        do_action('edited_term_taxonomy', $term, $taxonomy);
    }
}