Changeset 6569
- Timestamp:
- 06/16/2017 07:32:03 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r6544 r6569 82 82 'forum_id' => $forum_id 83 83 ) ); 84 85 // Maybe make private 86 if ( bbp_is_forum_private( $forum_id, false ) ) { 87 bbp_privatize_forum( $forum_id ); 88 89 // Maybe make hidden 90 } elseif ( bbp_is_forum_hidden( $forum_id, false ) ) { 91 bbp_hide_forum( $forum_id ); 92 93 // Publicize 94 } else { 95 bbp_publicize_forum( $forum_id ); 96 } 84 97 85 98 /** … … 2133 2146 */ 2134 2147 function bbp_exclude_forum_ids( $type = 'string' ) { 2135 static $types = array();2136 2148 2137 2149 // Setup arrays 2138 2150 $forum_ids = array(); 2139 2151 2140 // Capability performance optimization 2141 if ( ! empty( $types[ $type ] ) ) { 2142 $retval = $types[ $type ]; 2143 $forum_ids = $types['array']; 2144 2145 // Populate forum types 2146 } else { 2147 2148 // Types 2149 $types = array( 2150 'array' => array(), 2151 'string' => '', 2152 'meta_query' => array() 2153 ); 2154 2155 // Exclude for everyone but keymasters 2156 if ( ! bbp_is_user_keymaster() ) { 2157 2158 // Get forum IDs to exclude 2159 $forum_ids = bbp_get_excluded_forum_ids(); 2160 2161 // Store return values in static types array 2162 if ( ! empty( $forum_ids ) ) { 2163 2164 // Comparison 2165 $compare = ( 1 < count( $forum_ids ) ) 2166 ? 'NOT IN' 2167 : '!='; 2168 2169 // Setup types 2170 $types['array'] = $forum_ids; 2171 $types['string'] = implode( ',', $forum_ids ); 2172 $types['meta_query'] = array( 2173 'key' => '_bbp_forum_id', 2174 'value' => $types['string'], 2175 'type' => 'NUMERIC', 2176 'compare' => $compare 2177 ); 2178 } 2179 } 2180 2181 // There are forums that need to be excluded 2182 $retval = $types[ $type ]; 2183 } 2152 // Types 2153 $types = array( 2154 'array' => array(), 2155 'string' => '', 2156 'meta_query' => array() 2157 ); 2158 2159 // Exclude for everyone but keymasters 2160 if ( ! bbp_is_user_keymaster() ) { 2161 2162 // Get forum IDs to exclude 2163 $forum_ids = bbp_get_excluded_forum_ids(); 2164 2165 // Store return values in static types array 2166 if ( ! empty( $forum_ids ) ) { 2167 2168 // Comparison 2169 $compare = ( 1 < count( $forum_ids ) ) 2170 ? 'NOT IN' 2171 : '!='; 2172 2173 // Setup types 2174 $types['array'] = $forum_ids; 2175 $types['string'] = implode( ',', $forum_ids ); 2176 $types['meta_query'] = array( 2177 'key' => '_bbp_forum_id', 2178 'value' => $types['string'], 2179 'type' => 'NUMERIC', 2180 'compare' => $compare 2181 ); 2182 } 2183 } 2184 2185 // There are forums that need to be excluded 2186 $retval = $types[ $type ]; 2184 2187 2185 2188 // Filter & return … … 2230 2233 2231 2234 /** Default ***********************************************************/ 2232 2233 // Get any existing post status 2234 $post_stati = $posts_query->get( 'post_status' ); 2235 2236 // Default to public status 2237 if ( empty( $post_stati ) ) { 2238 $post_stati = array( bbp_get_public_status_id() ); 2239 2240 // Split the status string 2241 } elseif ( is_string( $post_stati ) ) { 2242 $post_stati = explode( ',', $post_stati ); 2243 } 2244 2245 /** Private ***********************************************************/ 2246 2247 // Remove bbp_get_private_status_id() if user is not capable 2248 if ( ! current_user_can( 'read_private_forums' ) ) { 2249 $key = array_search( bbp_get_private_status_id(), $post_stati, true ); 2250 if ( ! empty( $key ) ) { 2251 unset( $post_stati[ $key ] ); 2252 } 2253 2254 // ...or add it if they are 2255 } else { 2256 $post_stati[] = bbp_get_private_status_id(); 2257 } 2258 2259 /** Hidden ************************************************************/ 2260 2261 // Remove bbp_get_hidden_status_id() if user is not capable 2262 if ( ! current_user_can( 'read_hidden_forums' ) ) { 2263 $key = array_search( bbp_get_hidden_status_id(), $post_stati, true ); 2264 if ( ! empty( $key ) ) { 2265 unset( $post_stati[ $key ] ); 2266 } 2267 2268 // ...or add it if they are 2269 } else { 2270 $post_stati[] = bbp_get_hidden_status_id(); 2271 } 2272 2273 // Add the statuses 2274 $posts_query->set( 'post_status', array_unique( array_filter( $post_stati ) ) ); 2235 global $jjj; 2236 // Add all supported forum visibilities 2237 $posts_query->set( 'post_status', array_keys( bbp_get_forum_visibilities() ) ); 2238 2239 // Get forums to exclude 2240 $hidden_ids = bbp_exclude_forum_ids( 'array' ); 2241 2242 // Bail if no forums to exclude 2243 if ( empty( $hidden_ids ) ) { 2244 return; 2245 } 2246 2247 if ( true === $jjj ) { 2248 var_dump( bbp_get_private_forum_ids() ); die; 2249 } 2250 // Get any existing meta queries 2251 $not_in = $posts_query->get( 'post__not_in', array() ); 2252 2253 // Add our meta query to existing 2254 $not_in = array_unique( array_merge( $not_in, $hidden_ids ) ); 2255 2256 // Set the meta_query var 2257 $posts_query->set( 'post__not_in', $not_in ); 2275 2258 2276 2259 // Some other post type besides Forums, Topics, or Replies
Note: See TracChangeset
for help on using the changeset viewer.