bbp_admin_repair_topic_tag_count()
Recount topic in each topic-tag
Description Description
Return Return
(array) An array of the status code and the message
Source Source
File: includes/admin/tools/repair.php
function bbp_admin_repair_topic_tag_count() {
// Define variables
$statement = esc_html__( 'Counting the number of topics in each topic-tag… %s', 'bbpress' );
$result = esc_html__( 'Failed!', 'bbpress' );
$tax_id = bbp_get_topic_tag_tax_id();
$terms = get_terms( $tax_id, array( 'hide_empty' => false ) );
$tt_ids = wp_list_pluck( $terms, 'term_taxonomy_id' );
$ints = array_map( 'intval', $tt_ids );
$taxonomy = get_taxonomy( $tax_id );
// Bail if taxonomy does not exist
if ( empty( $taxonomy ) ) {
return array( 1, sprintf( $statement, $result ) );
}
// Custom callback
if ( ! empty( $taxonomy->update_count_callback ) ) {
// Bail if callback is not callable
if ( ! is_callable( $taxonomy->update_count_callback ) ) {
return array( 1, sprintf( $statement, $result ) );
}
call_user_func( $taxonomy->update_count_callback, $ints, $taxonomy );
// Generic callback fallback
} else {
_update_post_term_count( $ints, $taxonomy );
}
// Bust the cache
clean_term_cache( $ints, '', false );
return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |