Changeset 36402
- Timestamp:
- 01/26/2016 02:36:32 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r36316 r36402 1666 1666 * 1667 1667 * @since 4.4.0 1668 * 1669 * @param object $post_type_object Post type object. 1668 * @since 4.5.0 Added the ability to pass a post type name in addition to object. 1669 * 1670 * @param object $post_type Post type name or object. 1670 1671 * @return bool Whether the post type should be considered viewable. 1671 1672 */ 1672 function is_post_type_viewable( $post_type_object ) { 1673 return $post_type_object->publicly_queryable || ( $post_type_object->_builtin && $post_type_object->public ); 1673 function is_post_type_viewable( $post_type ) { 1674 if ( is_scalar( $post_type ) ) { 1675 $post_type = get_post_type_object( $post_type ); 1676 if ( ! $post_type ) { 1677 return false; 1678 } 1679 } 1680 1681 return $post_type->publicly_queryable || ( $post_type->_builtin && $post_type->public ); 1674 1682 } 1675 1683 -
trunk/tests/phpunit/tests/post/isPostTypeViewable.php
r36401 r36402 72 72 $this->assertTrue( is_post_type_viewable( $page ) ); 73 73 } 74 75 /** 76 * @ticket 35609 77 */ 78 public function test_should_accept_post_type_name() { 79 register_post_type( 'wptests_pt', array( 80 'publicly_queryable' => true, 81 '_builtin' => false, 82 'public' => false, 83 ) ); 84 85 $this->assertTrue( is_post_type_viewable( 'wptests_pt' ) ); 86 } 87 88 /** 89 * @ticket 35609 90 */ 91 public function test_should_return_false_for_bad_post_type_name() { 92 $this->assertFalse( is_post_type_viewable( 'foo' ) ); 93 } 74 94 }
Note: See TracChangeset
for help on using the changeset viewer.