Changeset 15795
- Timestamp:
- 10/13/2010 04:37:01 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r15794 r15795 2184 2184 $orderby = $q['orderby']; 2185 2185 2186 $pieces = array( 'where', 'groupby', 'join', 'orderby', 'distinct', 'fields', 'limits' ); 2187 2186 2188 // Apply post-paging filters on where and join. Only plugins that 2187 2189 // manipulate paging queries should use these hooks. 2188 2190 if ( !$q['suppress_filters'] ) { 2189 $ var_config = array(2190 'where' => 'posts_where_paged',2191 'groupby' => 'posts_groupby',2192 'join' => 'posts_join_paged',2193 'orderby' => 'posts_orderby',2194 'distinct' => 'posts_distinct',2195 'limits' => 'post_limits',2196 'fields' => 'posts_fields', 2197 );2198 $ var_values = compact( array_keys( $var_config) );2199 $result = $this->_filter_clause_variables( $var_config, $var_values, 'posts_clauses' );2200 extract( $result );2191 $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); 2192 $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); 2193 $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); 2194 $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); 2195 $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); 2196 $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); 2197 $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); 2198 2199 // Filter all clauses at once, for convenience 2200 $clauses = apply_filters_ref_array( 'posts_clauses', array( compact( $pieces ), &$this ) ); 2201 foreach ( $pieces as $piece ) 2202 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; 2201 2203 } 2202 2204 … … 2206 2208 // Filter again for the benefit of caching plugins. Regular plugins should use the hooks above. 2207 2209 if ( !$q['suppress_filters'] ) { 2208 $ var_config = array(2209 'where' => 'posts_where_request',2210 'groupby' => 'posts_groupby_request',2211 'join' => 'posts_join_request',2212 'orderby' => 'posts_orderby_request',2213 'distinct' => 'posts_distinct_request',2214 'fields' => 'posts_fields_request',2215 'limits' => 'post_limits_request', 2216 );2217 $ var_values = compact( array_keys( $var_config) );2218 $result = $this->_filter_clause_variables( $var_config, $var_values, 'posts_clauses_request' );2219 extract( $result );2210 $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); 2211 $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); 2212 $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); 2213 $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); 2214 $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); 2215 $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); 2216 $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); 2217 2218 // Filter all clauses at once, for convenience 2219 $clauses = apply_filters_ref_array( 'posts_clauses_request', array( compact( $pieces ), &$this ) ); 2220 foreach ( $pieces as $piece ) 2221 $$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : ''; 2220 2222 } 2221 2223 … … 2358 2360 return $this->posts; 2359 2361 } 2360 2361 /**2362 * Filter clause variables based on configuration. Once per clause and2363 * then all clauses at once.2364 *2365 * @access private2366 * @param array $config filternames keyed with their variable names2367 * @param array $values values keyed with their variable names2368 * @param string $all_filter_name for the "single filter"2369 * @return array filtered values keyed with their names2370 */2371 function _filter_clause_variables( $config, $values, $all_filter_name ) {2372 $clauses = array();2373 foreach ( $config as $variable_name => $filter ) {2374 $clauses[$variable_name] = apply_filters_ref_array( $filter, array( $values[$variable_name], &$this ) );2375 }2376 // run filter for all clauses at once2377 $clauses = apply_filters_ref_array( $all_filter_name, array( $clauses, &$this ) );2378 $is_array = is_array( $clauses );2379 $filtered = array();2380 foreach ( $config as $variable_name => $filter ) {2381 if ( $is_array && isset( $clauses[$variable_name] ) ) {2382 $filtered[$variable_name] = $clauses[$variable_name];2383 } else {2384 $filtered[$variable_name] = '';2385 }2386 }2387 return $filtered;2388 }2389 2362 2390 2363 /**
Note: See TracChangeset
for help on using the changeset viewer.