Changeset 6414
- Timestamp:
- 05/19/2017 02:44:11 AM (8 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/cache.php
r6058 r6414 181 181 // Loop through query types and clean caches 182 182 foreach ( $post_types as $post_type ) { 183 wp_cache_delete( 'bbp_parent_all_' . $post->ID . '_type_' . $post_type . '_child_ids', 'bbpress_posts' ); 184 } 185 186 /** 187 * Fires immediately after the given post's cache is cleaned. 183 $key = 'bbp_parent_all_' . $post->ID . '_type_' . $post_type . '_child_ids'; 184 wp_cache_delete( $key, 'bbpress_posts' ); 185 } 186 187 /** 188 * Fires immediately after the given post cache is cleaned. 188 189 * 189 190 * @since 2.1.0 -
trunk/src/includes/forums/functions.php
r6400 r6414 2090 2090 2091 2091 // Setup arrays 2092 $ private = $hidden = $meta_query = $forum_ids = array();2092 $forum_ids = array(); 2093 2093 2094 2094 // Capability performance optimization 2095 2095 if ( ! empty( $types[ $type ] ) ) { 2096 $retval = $types[ $type ]; 2097 2098 // Populate forum exclude type 2096 $retval = $types[ $type ]; 2097 $forum_ids = $types['array']; 2098 2099 // Populate forum types 2099 2100 } else { 2100 2101 2101 // Default return value 2102 switch ( $type ) { 2103 case 'string' : 2104 $retval = ''; 2105 break; 2106 2107 case 'array' : 2108 $retval = array(); 2109 break; 2110 2111 case 'meta_query' : 2112 $retval = array( array() ) ; 2113 break; 2114 } 2102 // Types 2103 $types = array( 2104 'array' => array(), 2105 'string' => '', 2106 'meta_query' => array() 2107 ); 2115 2108 2116 2109 // Exclude for everyone but keymasters … … 2118 2111 2119 2112 // Private forums 2120 if ( ! current_user_can( 'read_private_forums' ) ) { 2121 $private = bbp_get_private_forum_ids(); 2113 $private = ! current_user_can( 'read_private_forums' ) 2114 ? bbp_get_private_forum_ids() 2115 : array(); 2116 2117 // Hidden forums 2118 $hidden = ! current_user_can( 'read_hidden_forums' ) 2119 ? bbp_get_hidden_forum_ids() 2120 : array(); 2121 2122 // Merge private and hidden forums together and remove any empties 2123 $forum_ids = ( ! empty( $private ) || ! empty( $hidden ) ) 2124 ? array_filter( wp_parse_id_list( array_merge( $private, $hidden ) ) ) 2125 : array(); 2126 2127 // Comparison 2128 $compare = ( 1 < count( $forum_ids ) ) 2129 ? 'NOT IN' 2130 : '!='; 2131 2132 // Store return values in static types array 2133 if ( ! empty( $forum_ids ) ) { 2134 $types['array'] = $forum_ids; 2135 $types['string'] = implode( ',', $forum_ids ); 2136 $types['meta_query'] = array( 2137 'key' => '_bbp_forum_id', 2138 'value' => $forum_ids, 2139 'type' => 'NUMERIC', 2140 'compare' => $compare 2141 ); 2122 2142 } 2123 2124 // Hidden forums 2125 if ( ! current_user_can( 'read_hidden_forums' ) ) { 2126 $hidden = bbp_get_hidden_forum_ids(); 2127 } 2128 2129 // Merge private and hidden forums together 2130 $forum_ids = (array) array_filter( wp_parse_id_list( array_merge( $private, $hidden ) ) ); 2131 2132 // There are forums that need to be excluded 2133 if ( ! empty( $forum_ids ) ) { 2134 2135 switch ( $type ) { 2136 2137 // Separate forum ID's into a comma separated string 2138 case 'string' : 2139 $retval = implode( ',', $forum_ids ); 2140 break; 2141 2142 // Use forum_ids array 2143 case 'array' : 2144 $retval = $forum_ids; 2145 break; 2146 2147 // Build a meta_query 2148 case 'meta_query' : 2149 $retval = array( 2150 'key' => '_bbp_forum_id', 2151 'value' => implode( ',', $forum_ids ), 2152 'type' => 'NUMERIC', 2153 'compare' => ( 1 < count( $forum_ids ) ) ? 'NOT IN' : '!=' 2154 ); 2155 break; 2156 } 2157 } 2158 } 2159 2160 // Store return value in static types array 2161 $types[ $type ] = $retval; 2143 } 2144 2145 // There are forums that need to be excluded 2146 $retval = $types[ $type ]; 2162 2147 } 2163 2148 … … 2260 2245 2261 2246 // Bail if no forums to exclude 2262 if ( ! array_filter( $forum_ids ) ) {2247 if ( empty( $forum_ids ) ) { 2263 2248 return; 2264 2249 } … … 2570 2555 2571 2556 // Allowed post statuses to pre-trash 2572 $post_stati = implode( ',',array(2557 $post_stati = array( 2573 2558 bbp_get_public_status_id(), 2574 2559 bbp_get_closed_status_id(), 2575 2560 bbp_get_pending_status_id() 2576 ) );2561 ); 2577 2562 2578 2563 // Forum is being trashed, so its topics and replies are trashed too -
trunk/src/includes/forums/template.php
r6384 r6414 722 722 'post_parent' => 0, 723 723 'post_type' => bbp_get_forum_post_type(), 724 'post_status' => implode( ',', $post_stati ),724 'post_status' => $post_stati, 725 725 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ), 726 726 'orderby' => 'menu_order title', -
trunk/src/includes/replies/template.php
r6396 r6414 168 168 169 169 // Join post statuses together 170 $default['post_status'] = implode( ',', $post_statuses );170 $default['post_status'] = $post_statuses; 171 171 172 172 // Lean on the 'perm' query var value of 'readable' to provide statuses -
trunk/src/includes/search/template.php
r6300 r6414 80 80 81 81 // Join post statuses together 82 $default['post_status'] = implode( ',', $post_statuses );82 $default['post_status'] = $post_statuses; 83 83 84 84 // Lean on the 'perm' query var value of 'readable' to provide statuses -
trunk/src/includes/topics/template.php
r6402 r6414 184 184 185 185 // Join post statuses together 186 $default['post_status'] = implode( ',', $post_statuses );186 $default['post_status'] = $post_statuses; 187 187 188 188 // Lean on the 'perm' query var value of 'readable' to provide statuses -
trunk/src/includes/users/template.php
r6384 r6414 2287 2287 function bbp_get_forums_for_current_user( $args = array() ) { 2288 2288 2289 // Setup arrays2290 $private = $hidden = $exclude = array();2291 2292 // Private forums2293 if ( ! current_user_can( 'read_private_forums' ) ) {2294 $private = bbp_get_private_forum_ids();2295 }2296 2297 // Hidden forums2298 if ( ! current_user_can( 'read_hidden_forums' ) ) {2299 $hidden = bbp_get_hidden_forum_ids();2300 }2301 2302 // Merge private and hidden forums together and remove any empties2303 $forum_ids = (array) array_filter( wp_parse_id_list( array_merge( $private, $hidden ) ) );2304 2305 // There are forums that need to be excluded2306 if ( ! empty( $forum_ids ) ) {2307 $exclude = implode( ',', $forum_ids );2308 }2309 2310 2289 // Parse arguments against default values 2311 2290 $r = bbp_parse_args( $args, array( 2312 'post_type' => bbp_get_forum_post_type(),2313 'post_status' => bbp_get_public_status_id(),2314 ' numberposts' => -1,2315 ' exclude' => $exclude2291 'post_type' => bbp_get_forum_post_type(), 2292 'post_status' => bbp_get_public_status_id(), 2293 'post__not_in' => bbp_exclude_forum_ids( 'array' ), 2294 'numberposts' => -1 2316 2295 ), 'get_forums_for_current_user' ); 2317 2296 … … 2324 2303 } 2325 2304 2326 return apply_filters( 'bbp_get_forums_for_current_user', $forums );2305 return apply_filters( 'bbp_get_forums_for_current_user', $forums, $r, $args ); 2327 2306 } 2328 2307
Note: See TracChangeset
for help on using the changeset viewer.