bbp_update_topic_reply_count_hidden( int $topic_id, int $reply_count )
Adjust the total hidden reply count of a topic (hidden includes trashed and spammed replies)
Description
Parameters
- $topic_id
-
(Optional) Topic id to update
- $reply_count
-
(Optional) Set the reply count manually
Return
(int) Topic hidden reply count
Source
File: bp-forums/topics/functions.php
2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 | function bbp_update_topic_reply_count_hidden( $topic_id = 0, $reply_count = 0 ) { global $wpdb ; // If it's a reply, then get the parent (topic id) if ( bbp_is_reply( $topic_id ) ) { $topic_id = bbp_get_reply_topic_id( $topic_id ); } else { $topic_id = bbp_get_topic_id( $topic_id ); } // Get replies of topic if ( empty ( $reply_count ) ) { $post_status = "'" . implode( "','" , array ( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "'" ; $reply_count = $wpdb ->get_var( $wpdb ->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';" , $topic_id , bbp_get_reply_post_type() ) ); } update_post_meta( $topic_id , '_bbp_reply_count_hidden' , (int) $reply_count ); return apply_filters( 'bbp_update_topic_reply_count_hidden' , (int) $reply_count , $topic_id ); } |
Changelog
Version | Description |
---|---|
bbPress (r2740) | 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.