Ticket #21949: 21949.wp-class.2.patch
| File 21949.wp-class.2.patch, 3.2 KB (added by , 13 years ago) |
|---|
-
wp-includes/class-wp.php
278 278 } 279 279 } 280 280 } 281 281 282 // Only get $queryable_taxonomies if needed 283 $queryable_taxonomies = null; 284 282 285 // Convert urldecoded spaces back into + 283 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) 284 if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) 286 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) { 287 if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) { 285 288 $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); 286 289 } 290 291 // Limit publicly queried taxonomy to those that are public 292 // for taxonomy query_vars 293 if ( isset( $this->query_vars[$t->query_var] ) ) { 294 // Only get $queryable_taxonomies if needed 295 if ( null === $queryable_taxonomies ) 296 $queryable_taxonomies = get_taxonomies( array( 'public' => true ) ); 297 $this->_limit_public( $t->query_var, $queryable_taxonomies ); 298 } 299 } 300 301 // Limit publicly queried taxonomy to those that are public 302 // for query_var taxonomy 303 if ( isset( $this->query_vars['taxonomy'] ) ) { 304 // Only get $queryable_taxonomies if needed 305 if ( null === $queryable_taxonomies ) 306 $queryable_taxonomies = get_taxonomies( array( 'public' => true ) ); 307 $this->_limit_public( 'taxonomy', $queryable_taxonomies ); 308 } 309 287 310 // Limit publicly queried post_types to those that are publicly_queryable 288 311 if ( isset( $this->query_vars['post_type']) ) { 289 312 $queryable_post_types = get_post_types( array('publicly_queryable' => true) ); 290 if ( ! is_array( $this->query_vars['post_type'] ) ) { 291 if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) 292 unset( $this->query_vars['post_type'] ); 293 } else { 294 $this->query_vars['post_type'] = array_intersect( $this->query_vars['post_type'], $queryable_post_types ); 295 } 313 $this->_limit_public( 'post_type', $queryable_post_types ); 296 314 } 297 315 298 316 foreach ( (array) $this->private_query_vars as $var) { 299 317 if ( isset($this->extra_query_vars[$var]) ) 300 318 $this->query_vars[$var] = $this->extra_query_vars[$var]; … … 307 325 308 326 do_action_ref_array('parse_request', array(&$this)); 309 327 } 328 329 /** 330 * Helper function to limit query_vars to those that are public. 331 * 332 * Removes non-public (taxonomy) and non-publicly_queryable (post_types) query_vars. 333 * Also, removes term if taxonomy is not public. 334 * 335 * @since 3.5.0 336 * 337 * @param string|array $qv Query var being tested, e.g., taxonomy, post_type, {taxonomy_name}. 338 * @param array $queryable_qvs Array of acceptable public query vars. 339 */ 340 function _limit_public( $qv, $queryable_qvs ) { 341 if ( ! is_array( $this->query_vars[$qv] ) ) { 342 if ( ! in_array( $this->query_vars[$qv], $queryable_qvs ) ) { 343 unset( $this->query_vars[$qv] ); 344 if ( 'taxonomy' == $qv ) 345 unset( $this->query_vars['term'] ); 346 } 347 } else { 348 $this->query_vars[$qv] = array_intersect( $this->query_vars[$qv], $queryable_qvs ); 349 } 350 } 310 351 311 352 /** 312 353 * Send additional HTTP headers for caching, content type, etc.