From d1386b1bee7e6b51f3625df9a16b83156d36c910 Mon Sep 17 00:00:00 2001 From: SirLouen Date: Mon, 4 Nov 2024 12:51:27 +0100 Subject: [PATCH] Patching Issue #3609 --- src/includes/forums/functions.php | 37 ++++++++++++++----------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/includes/forums/functions.php b/src/includes/forums/functions.php index fa54e9d8..3c5f8c43 100644 --- a/src/includes/forums/functions.php +++ b/src/includes/forums/functions.php @@ -2314,33 +2314,30 @@ function bbp_pre_get_posts_normalize_forum_visibility( $posts_query = null ) { return; } - // Forums - if ( in_array( bbp_get_forum_post_type(), $post_types, true ) ) { - - /** Default ***********************************************************/ + if ( ! array_diff( $post_types, bbp_get_post_types() ) ) { + + // Specific normalization for Forums Post Type + if ( in_array( bbp_get_forum_post_type(), $post_types, true ) ) { - // Add all supported forum visibilities - $posts_query->set( 'post_status', array_keys( bbp_get_forum_visibilities() ) ); + // Add all supported forum visibilities + $posts_query->set( 'post_status', array_keys( bbp_get_forum_visibilities() ) ); - // Get forums to exclude - $forum_ids = bbp_exclude_forum_ids( 'array' ); + // Get forums to exclude + $forum_ids = bbp_exclude_forum_ids( 'array' ); - // Excluding some forums - if ( ! empty( $forum_ids ) ) { + // Excluding some forums + if ( ! empty( $forum_ids ) ) { - // Get any existing not-in queries - $not_in = $posts_query->get( 'post__not_in', array() ); + // Get any existing not-in queries + $not_in = $posts_query->get( 'post__not_in', array() ); - // Add our not-in to existing - $not_in = array_unique( array_merge( $not_in, $forum_ids ) ); + // Add our not-in to existing + $not_in = array_unique( array_merge( $not_in, $forum_ids ) ); - // Set the new not-in val - $posts_query->set( 'post__not_in', $not_in ); + // Set the new not-in val + $posts_query->set( 'post__not_in', $not_in ); + } } - } - - // Any bbPress post type - if ( ! array_diff( $post_types, bbp_get_post_types() ) ) { // Get forums to exclude $forum_ids = bbp_exclude_forum_ids( 'meta_query' );