bbp_repair_forum_visibility()
Recaches the private and hidden forums
Description Description
Return Return
(array) An array of the status code and the message
Source Source
File: includes/forums/functions.php
function bbp_repair_forum_visibility() { // First, delete everything. delete_option( '_bbp_private_forums' ); delete_option( '_bbp_hidden_forums' ); /** * Don't search for both private/hidden statuses. Since 'pre_get_posts' is an * action, it's not removed by suppress_filters. We need to make sure that * we're only searching for the supplied post_status. * * @see https://bbpress.trac.wordpress.org/ticket/2512 */ remove_action( 'pre_get_posts', 'bbp_pre_get_posts_normalize_forum_visibility', 4 ); // Query for private forums $private_forums = new WP_Query( array( 'fields' => 'ids', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_private_status_id(), 'posts_per_page' => -1, // Performance 'nopaging' => true, 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'ignore_sticky_posts' => true, 'no_found_rows' => true ) ); // Query for hidden forums $hidden_forums = new WP_Query( array( 'fields' => 'ids', 'suppress_filters' => true, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_hidden_status_id(), 'posts_per_page' => -1, // Performance 'nopaging' => true, 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'ignore_sticky_posts' => true, 'no_found_rows' => true ) ); // Enable forum visibilty normalization add_action( 'pre_get_posts', 'bbp_pre_get_posts_normalize_forum_visibility', 4 ); // Reset the $post global wp_reset_postdata(); // Private if ( ! is_wp_error( $private_forums ) ) { update_option( '_bbp_private_forums', $private_forums->posts ); } // Hidden forums if ( ! is_wp_error( $hidden_forums ) ) { update_option( '_bbp_hidden_forums', $hidden_forums->posts ); } // Complete results return true; }
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Introduced. |