bbp_admin_repair_forum_topic_count

Recount forum topics.

Description

(array) bbp_admin_repair_forum_topic_count(); 

Returns (array)

An array of the status code and the message


Usage

  1. if ( !function_exists( 'bbp_admin_repair_forum_topic_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/admin/tools.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_admin_repair_forum_topic_count(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/tools.php  
  1. function bbp_admin_repair_forum_topic_count() { 
  2. global $wpdb; 
  3.  
  4. $statement = __( 'Counting the number of topics in each forum… %s', bbpress ); 
  5. $result = __( 'Failed!', bbpress ); 
  6.  
  7. $sql_delete = "DELETE FROM {$wpdb->postmeta} WHERE meta_key IN ( '_bbp_topic_count', '_bbp_total_topic_count' );"; 
  8. if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) 
  9. return array( 1, sprintf( $statement, $result ) ); 
  10.  
  11. $forums = get_posts( array( 'post_type' => bbp_get_forum_post_type(), 'numberposts' => -1 ) ); 
  12. if ( !empty( $forums ) ) { 
  13. foreach ( $forums as $forum ) { 
  14. } else { 
  15. return array( 2, sprintf( $statement, $result ) ); 
  16.  
  17. return array( 0, sprintf( $statement, __( 'Complete!', bbpress ) ) );