Changeset 25659
- Timestamp:
- 10/02/2013 07:41:19 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp.php
r25617 r25659 239 239 $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); 240 240 241 foreach ( $GLOBALS['wp_post_types']as $post_type => $t )241 foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) 242 242 if ( $t->query_var ) 243 243 $post_type_query_vars[$t->query_var] = $post_type; … … 272 272 273 273 // Convert urldecoded spaces back into + 274 foreach ( $GLOBALS['wp_taxonomies']as $taxonomy => $t )274 foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) 275 275 if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) 276 276 $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); -
trunk/src/wp-includes/query.php
r25632 r25659 1736 1736 } 1737 1737 1738 foreach ( $GLOBALS['wp_taxonomies']as $taxonomy => $t ) {1738 foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t ) { 1739 1739 if ( 'post_tag' == $taxonomy ) 1740 1740 continue; // Handled further down in the $q['tag'] block -
trunk/src/wp-includes/rewrite.php
r25464 r25659 339 339 340 340 $request = $url; 341 $post_type_query_vars = array(); 342 343 foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) { 344 if ( ! empty( $t->query_var ) ) 345 $post_type_query_vars[ $t->query_var ] = $post_type; 346 } 341 347 342 348 // Look for matches. … … 366 372 // Filter out non-public query vars 367 373 global $wp; 368 parse_str( $query, $query_vars);374 parse_str( $query, $query_vars ); 369 375 $query = array(); 370 376 foreach ( (array) $query_vars as $key => $value ) { 371 if ( in_array( $key, $wp->public_query_vars) )377 if ( in_array( $key, $wp->public_query_vars ) ){ 372 378 $query[$key] = $value; 379 if ( isset( $post_type_query_vars[$key] ) ) { 380 $query['post_type'] = $post_type_query_vars[$key]; 381 $query['name'] = $value; 382 } 383 } 373 384 } 374 385 375 386 // Do the query 376 $query = new WP_Query( $query);377 if ( ! empty($query->posts) && $query->is_singular )387 $query = new WP_Query( $query ); 388 if ( ! empty( $query->posts ) && $query->is_singular ) 378 389 return $query->post->ID; 379 390 else -
trunk/tests/phpunit/tests/rewrite.php
r25258 r25659 33 33 } 34 34 35 function test_url_to_postid_custom_post_type() { 36 delete_option( 'rewrite_rules' ); 37 38 $post_type = rand_str( 12 ); 39 register_post_type( $post_type, array( 'public' => true ) ); 40 41 $id = $this->factory->post->create( array( 'post_type' => $post_type ) ); 42 $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); 43 44 _unregister_post_type( $post_type ); 45 } 46 35 47 function test_url_to_postid_hierarchical() { 36 48
Note: See TracChangeset
for help on using the changeset viewer.