Changeset 3433 for branches/plugin/bbp-includes/bbp-forum-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-forum-functions.php
r3431 r3433 866 866 867 867 /** 868 * Adjusts topic and reply queries to exclude items that might be contained 869 * inside hidden or private forums that the user does not have the capability 870 * to view. 871 * 872 * @since bbPress (r3291) 873 * 874 * @param WP_Query $posts_query 875 * 876 * @uses apply_filters() 877 * @uses bbp_exclude_forum_ids() 878 * @uses bbp_get_topic_post_type() 879 * @uses bbp_get_reply_post_type() 880 881 * @return WP_Query 882 */ 883 function bbp_pre_get_posts_exclude_forums( $posts_query ) { 884 885 // Bail if all forums are explicitly allowed 886 if ( true === apply_filters( 'bbp_include_all_forums', $posts_query ) ) 887 return $posts_query; 888 889 // Bail if $posts_query is not an object or of incorrect class 890 if ( !is_object( $posts_query ) || ( 'WP_Query' != get_class( $posts_query ) ) ) 891 return $posts_query; 892 893 // Bail if filters are suppressed on this query 894 if ( true == $posts_query->get( 'suppress_filters' ) ) 895 return $posts_query; 896 897 // There are forums that need to be excluded 898 if ( $forum_ids = bbp_exclude_forum_ids( 'meta_query' ) ) { 899 900 // Only exclude forums on bbPress queries 901 switch ( $posts_query->get( 'post_type' ) ) { 902 903 // Topics 904 case bbp_get_topic_post_type() : 905 906 // Replies 907 case bbp_get_reply_post_type() : 908 909 // Topics and replies 910 case array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ) : 911 912 // Get any existing meta queries 913 $meta_query = $posts_query->get( 'meta_query' ); 914 915 // Add our meta query to existing 916 $meta_query[] = $forum_ids; 917 918 // Set the meta_query var 919 $posts_query->set( 'meta_query', $meta_query ); 920 921 break; 922 } 923 } 924 925 // Return possibly adjusted query 926 return $posts_query; 927 } 928 929 /** 868 930 * Returns the forum's topic ids 869 931 *
Note: See TracChangeset
for help on using the changeset viewer.