Changeset 6923 for trunk/src/includes/admin/tools/repair.php
- Timestamp:
- 11/09/2019 05:35:42 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/repair.php
r6908 r6923 263 263 264 264 /** 265 * Recount topic hidden replies (spammed/trashed)265 * Recount non-public replies per topic (pending/spammed/trashed) 266 266 * 267 267 * @since 2.0.0 bbPress (r2747) … … 405 405 foreach ( $forums as $forum ) { 406 406 bbp_update_forum_reply_count( $forum->ID ); 407 } 408 } else { 409 return array( 2, sprintf( $statement, $result ) ); 410 } 411 412 return array( 0, sprintf( $statement, esc_html__( 'Complete!', 'bbpress' ) ) ); 413 } 414 415 /** 416 * Recount non-public forum replies 417 * 418 * @since 2.6.0 bbPress (r6922) 419 * 420 * @return array An array of the status code and the message 421 */ 422 function bbp_admin_repair_forum_reply_count_hidden() { 423 424 // Define variables 425 $bbp_db = bbp_db(); 426 $statement = esc_html__( 'Counting the number of pending, spammed, and trashed replies in each forum… %s', 'bbpress' ); 427 $result = esc_html__( 'Failed!', 'bbpress' ); 428 429 // Post type 430 $fpt = bbp_get_forum_post_type(); 431 432 // Delete the meta keys _bbp_reply_count and _bbp_total_reply_count for each forum 433 $sql_delete = "DELETE `postmeta` FROM `{$bbp_db->postmeta}` AS `postmeta` 434 LEFT JOIN `{$bbp_db->posts}` AS `posts` ON `posts`.`ID` = `postmeta`.`post_id` 435 WHERE `posts`.`post_type` = '{$fpt}' 436 AND `postmeta`.`meta_key` = '_bbp_reply_count_hidden' 437 OR `postmeta`.`meta_key` = '_bbp_total_reply_count_hidden'"; 438 439 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 440 return array( 1, sprintf( $statement, $result ) ); 441 } 442 443 // Recalculate the metas key _bbp_reply_count and _bbp_total_reply_count for each forum 444 $forums = get_posts( array( 'post_type' => bbp_get_forum_post_type(), 'numberposts' => -1 ) ); 445 if ( ! empty( $forums ) ) { 446 foreach ( $forums as $forum ) { 447 bbp_update_forum_reply_count_hidden( $forum->ID ); 407 448 } 408 449 } else {
Note: See TracChangeset
for help on using the changeset viewer.