bbp_admin_repair_topic_hidden_reply_count()
Recount topic hidden replies (spammed/trashed)
Description
Return
(array) An array of the status code and the message
Source
File: bp-forums/admin/tools.php
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | function bbp_admin_repair_topic_hidden_reply_count() { global $wpdb ; $statement = __( 'Counting the number of spammed and trashed replies in each discussion… %s' , 'buddyboss' ); $result = __( 'Failed!' , 'buddyboss' ); $sql_delete = "DELETE FROM `{$wpdb->postmeta}` WHERE `meta_key` = '_bbp_reply_count_hidden';" ; if ( is_wp_error( $wpdb ->query( $sql_delete ) ) ) return array ( 1, sprintf( $statement , $result ) ); $sql = "INSERT INTO `{$wpdb->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$wpdb->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` IN ( '" . implode( "','" , array ( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "') GROUP BY `post_parent`);" ; if ( is_wp_error( $wpdb ->query( $sql ) ) ) return array ( 2, sprintf( $statement , $result ) ); return array ( 0, sprintf( $statement , __( 'Complete!' , 'buddyboss' ) ) ); } |
Changelog
Version | Description |
---|---|
bbPress (r2747) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.