| @@ 220-246 (lines=27) @@ | ||
| 217 | } | |
| 218 | ||
| 219 | // copied from class.json-api-endpoints.php | |
| 220 | 	public function is_post_type_allowed( $post_type ) { | |
| 221 | // if the post type is empty, that's fine, WordPress will default to post | |
| 222 | 		if ( empty( $post_type ) ) { | |
| 223 | return true; | |
| 224 | } | |
| 225 | ||
| 226 | // allow special 'any' type | |
| 227 | 		if ( 'any' == $post_type ) { | |
| 228 | return true; | |
| 229 | } | |
| 230 | ||
| 231 | // check for allowed types | |
| 232 | 		if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { | |
| 233 | return true; | |
| 234 | } | |
| 235 | ||
| 236 | 		if ( $post_type_object = get_post_type_object( $post_type ) ) { | |
| 237 | 			if ( ! empty( $post_type_object->show_in_rest ) ) { | |
| 238 | return $post_type_object->show_in_rest; | |
| 239 | } | |
| 240 | 			if ( ! empty( $post_type_object->publicly_queryable ) ) { | |
| 241 | return $post_type_object->publicly_queryable; | |
| 242 | } | |
| 243 | } | |
| 244 | ||
| 245 | return ! empty( $post_type_object->public ); | |
| 246 | } | |
| 247 | ||
| 248 | // copied from class.json-api-endpoints.php | |
| 249 | /** | |
| @@ 1735-1761 (lines=27) @@ | ||
| 1732 | } | |
| 1733 | } | |
| 1734 | ||
| 1735 | 	function is_post_type_allowed( $post_type ) { | |
| 1736 | // if the post type is empty, that's fine, WordPress will default to post | |
| 1737 | 		if ( empty( $post_type ) ) { | |
| 1738 | return true; | |
| 1739 | } | |
| 1740 | ||
| 1741 | // allow special 'any' type | |
| 1742 | 		if ( 'any' == $post_type ) { | |
| 1743 | return true; | |
| 1744 | } | |
| 1745 | ||
| 1746 | // check for allowed types | |
| 1747 | 		if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { | |
| 1748 | return true; | |
| 1749 | } | |
| 1750 | ||
| 1751 | 		if ( $post_type_object = get_post_type_object( $post_type ) ) { | |
| 1752 | 			if ( ! empty( $post_type_object->show_in_rest ) ) { | |
| 1753 | return $post_type_object->show_in_rest; | |
| 1754 | } | |
| 1755 | 			if ( ! empty( $post_type_object->publicly_queryable ) ) { | |
| 1756 | return $post_type_object->publicly_queryable; | |
| 1757 | } | |
| 1758 | } | |
| 1759 | ||
| 1760 | return ! empty( $post_type_object->public ); | |
| 1761 | } | |
| 1762 | ||
| 1763 | /** | |
| 1764 | * Gets the whitelisted post types that JP should allow access to. | |