Changeset 3433
- Timestamp:
- 08/21/2011 12:57:38 AM (15 years ago)
- Location:
- branches/plugin/bbp-includes
- Files:
-
- 2 edited
-
bbp-common-functions.php (modified) (1 diff)
-
bbp-forum-functions.php (modified) (1 diff)
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 * -
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.