mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@25659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -32,6 +32,18 @@ class Tests_Rewrite extends WP_UnitTestCase {
|
||||
$this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
|
||||
}
|
||||
|
||||
function test_url_to_postid_custom_post_type() {
|
||||
delete_option( 'rewrite_rules' );
|
||||
|
||||
$post_type = rand_str( 12 );
|
||||
register_post_type( $post_type, array( 'public' => true ) );
|
||||
|
||||
$id = $this->factory->post->create( array( 'post_type' => $post_type ) );
|
||||
$this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
|
||||
|
||||
_unregister_post_type( $post_type );
|
||||
}
|
||||
|
||||
function test_url_to_postid_hierarchical() {
|
||||
|
||||
$parent_id = $this->factory->post->create( array( 'post_title' => 'Parent', 'post_type' => 'page' ) );
|
||||
|
||||
Reference in New Issue
Block a user