Changeset 6414 for trunk/src/includes/forums/functions.php
- Timestamp:
- 05/19/2017 02:44:11 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.