Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/21/2011 12:57:38 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Move bbp_pre_get_posts_exclude_forums() to bbp-forum-functions.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-functions.php

    r3387 r3433  
    921921
    922922/**
    923  * Adjusts topic and reply queries to exclude items that might be contained
    924  * inside hidden or private forums that the user does not have the capability
    925  * to view.
    926  *
    927  * @since bbPress (r3291)
    928  *
    929  * @param WP_Query $posts_query
    930  *
    931  * @uses apply_filters()
    932  * @uses bbp_exclude_forum_ids()
    933  * @uses bbp_get_topic_post_type()
    934  * @uses bbp_get_reply_post_type()
    935 
    936  * @return WP_Query
    937  */
    938 function bbp_pre_get_posts_exclude_forums( $posts_query ) {
    939 
    940     // Bail if all forums are explicitly allowed
    941     if ( true === apply_filters( 'bbp_include_all_forums', $posts_query ) )
    942         return $posts_query;
    943 
    944     // Bail if $posts_query is not an object or of incorrect class
    945     if ( !is_object( $posts_query ) || ( 'WP_Query' != get_class( $posts_query ) ) )
    946         return $posts_query;
    947 
    948     // Bail if filters are suppressed on this query
    949     if ( true == $posts_query->get( 'suppress_filters' ) )
    950         return $posts_query;
    951 
    952     // There are forums that need to be excluded
    953     if ( $forum_ids = bbp_exclude_forum_ids( 'meta_query' ) ) {
    954 
    955         // Only exclude forums on bbPress queries
    956         switch ( $posts_query->get( 'post_type' ) ) {
    957 
    958             // Topics
    959             case bbp_get_topic_post_type() :
    960 
    961             // Replies
    962             case bbp_get_reply_post_type() :
    963 
    964             // Topics and replies
    965             case array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) :
    966 
    967                 // Get any existing meta queries
    968                 $meta_query   = $posts_query->get( 'meta_query' );
    969 
    970                 // Add our meta query to existing
    971                 $meta_query[] = $forum_ids;
    972 
    973                 // Set the meta_query var
    974                 $posts_query->set( 'meta_query', $meta_query );
    975 
    976                 break;
    977         }
    978     }
    979 
    980     // Return possibly adjusted query
    981     return $posts_query;
    982 }
    983 
    984 /**
    985923 * Adds ability to include or exclude specific post_parent ID's
    986924 *
Note: See TracChangeset for help on using the changeset viewer.