/** * Update the custom taxonomies' term counts when a post's status is changed. For example, default posts term counts (for custom taxonomies) don't include private / draft posts. * * @access private * @param string $new_status * @param string $old_status * @param object $post * @since 3.3.0 */ function _update_term_count_on_transition_post_status($new_status, $old_status, $post) { // Update counts for the post's terms. foreach ((array) get_object_taxonomies($post->post_type) as $taxonomy) { $tt_ids = nxt_get_object_terms($post->ID, $taxonomy, array('fields' => 'tt_ids')); nxt_update_term_count($tt_ids, $taxonomy); } }
/** * Enable or disable term counting. * * @since 2.5.0 * * @param bool $defer Optional. Enable if true, disable if false. * @return bool Whether term counting is enabled or disabled. */ function nxt_defer_term_counting($defer = null) { static $_defer = false; if (is_bool($defer)) { $_defer = $defer; // flush any deferred counts if (!$defer) { nxt_update_term_count(null, null, true); } } return $_defer; }