Changeset 3433 for branches/plugin/bbp-includes/bbp-common-functions.php
- Timestamp:
- 08/21/2011 12:57:38 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-common-functions.php
r3387 r3433 921 921 922 922 /** 923 * Adjusts topic and reply queries to exclude items that might be contained924 * inside hidden or private forums that the user does not have the capability925 * to view.926 *927 * @since bbPress (r3291)928 *929 * @param WP_Query $posts_query930 *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_Query937 */938 function bbp_pre_get_posts_exclude_forums( $posts_query ) {939 940 // Bail if all forums are explicitly allowed941 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 class945 if ( !is_object( $posts_query ) || ( 'WP_Query' != get_class( $posts_query ) ) )946 return $posts_query;947 948 // Bail if filters are suppressed on this query949 if ( true == $posts_query->get( 'suppress_filters' ) )950 return $posts_query;951 952 // There are forums that need to be excluded953 if ( $forum_ids = bbp_exclude_forum_ids( 'meta_query' ) ) {954 955 // Only exclude forums on bbPress queries956 switch ( $posts_query->get( 'post_type' ) ) {957 958 // Topics959 case bbp_get_topic_post_type() :960 961 // Replies962 case bbp_get_reply_post_type() :963 964 // Topics and replies965 case array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) :966 967 // Get any existing meta queries968 $meta_query = $posts_query->get( 'meta_query' );969 970 // Add our meta query to existing971 $meta_query[] = $forum_ids;972 973 // Set the meta_query var974 $posts_query->set( 'meta_query', $meta_query );975 976 break;977 }978 }979 980 // Return possibly adjusted query981 return $posts_query;982 }983 984 /**985 923 * Adds ability to include or exclude specific post_parent ID's 986 924 *
Note: See TracChangeset
for help on using the changeset viewer.