Make WordPress Core


Ignore:
Timestamp:
10/02/2013 07:41:19 PM (11 years ago)
Author:
wonderboymusic
Message:

Make url_to_postid() work for custom post type URLs. Use get_post_types() and get_taxonomies() instead of directly accessing globals. Adds unit test.

Props faishal, for the globals fix.
Fixes #19744.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r25617 r25659  
    239239        $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars);
    240240
    241         foreach ( $GLOBALS['wp_post_types'] as $post_type => $t )
     241        foreach ( get_post_types( array(), 'objects' ) as $post_type => $t )
    242242            if ( $t->query_var )
    243243                $post_type_query_vars[$t->query_var] = $post_type;
     
    272272
    273273        // Convert urldecoded spaces back into +
    274         foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t )
     274        foreach ( get_taxonomies( array() , 'objects' ) as $taxonomy => $t )
    275275            if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
    276276                $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
Note: See TracChangeset for help on using the changeset viewer.