Allow is_post_type_viewable() to accept a post type name.

Previously, it accepted only a post type object.

Props spacedmonkey.
Fixes #35609.

git-svn-id: https://develop.svn.wordpress.org/trunk@36402 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-01-26 02:36:32 +00:00
parent 81d3d79c1f
commit af5a3b663f
2 changed files with 31 additions and 3 deletions

View File

@@ -71,4 +71,24 @@ class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
$page = get_post_type_object( 'page' );
$this->assertTrue( is_post_type_viewable( $page ) );
}
/**
* @ticket 35609
*/
public function test_should_accept_post_type_name() {
register_post_type( 'wptests_pt', array(
'publicly_queryable' => true,
'_builtin' => false,
'public' => false,
) );
$this->assertTrue( is_post_type_viewable( 'wptests_pt' ) );
}
/**
* @ticket 35609
*/
public function test_should_return_false_for_bad_post_type_name() {
$this->assertFalse( is_post_type_viewable( 'foo' ) );
}
}