bbp_update_forum( array $args = array() )
Updates the counts of a forum.
Description Description
This calls a few internal functions that all run manual queries against the database to get their results. As such, this function can be costly to run but is necessary to keep everything accurate.
Parameters Parameters
- $args
-
(Optional) Supports these arguments: - forum_id: Forum id - last_topic_id: Last topic id - last_reply_id: Last reply id - last_active_id: Last active post id - last_active_time: last active time
Default value: array()
Source Source
File: includes/forums/functions.php
function bbp_update_forum( $args = array() ) { // Parse arguments against default values $r = bbp_parse_args( $args, array( 'forum_id' => 0, 'post_parent' => 0, 'last_topic_id' => 0, 'last_reply_id' => 0, 'last_active_id' => 0, 'last_active_time' => 0, 'last_active_status' => bbp_get_public_status_id() ), 'update_forum' ); // Update the forum parent bbp_update_forum_id( $r['forum_id'], $r['post_parent'] ); // Last topic and reply ID's bbp_update_forum_last_topic_id( $r['forum_id'], $r['last_topic_id'] ); bbp_update_forum_last_reply_id( $r['forum_id'], $r['last_reply_id'] ); // Active dance $r['last_active_id'] = bbp_update_forum_last_active_id( $r['forum_id'], $r['last_active_id'] ); // If no active time was passed, get it from the last_active_id if ( empty( $r['last_active_time'] ) ) { $r['last_active_time'] = get_post_field( 'post_date', $r['last_active_id'] ); } if ( bbp_get_public_status_id() === $r['last_active_status'] ) { bbp_update_forum_last_active_time( $r['forum_id'], $r['last_active_time'] ); } // Counts bbp_update_forum_subforum_count( $r['forum_id'] ); // Only update topic count if we've deleted a topic if ( in_array( current_filter(), array( 'bbp_deleted_topic', 'save_post' ), true ) ) { bbp_update_forum_reply_count( $r['forum_id'] ); bbp_update_forum_topic_count( $r['forum_id'] ); bbp_update_forum_topic_count_hidden( $r['forum_id'] ); bbp_update_forum_reply_count_hidden( $r['forum_id'] ); } // Update the parent forum if one was passed if ( ! empty( $r['post_parent'] ) && is_numeric( $r['post_parent'] ) ) { bbp_update_forum( array( 'forum_id' => $r['post_parent'], 'post_parent' => get_post_field( 'post_parent', $r['post_parent'] ) ) ); } // Bump the custom query cache wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |