Make WordPress Core


Ignore:
Timestamp:
10/02/2013 07:41:19 PM (12 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/tests/phpunit/tests/rewrite.php

    r25258 r25659  
    3333    }
    3434
     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   
    3547    function test_url_to_postid_hierarchical() {
    3648
Note: See TracChangeset for help on using the changeset viewer.