| @@ 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. |
|
| @@ 228-254 (lines=27) @@ | ||
| 225 | } |
|
| 226 | ||
| 227 | // copied from class.json-api-endpoints.php |
|
| 228 | public function is_post_type_allowed( $post_type ) { |
|
| 229 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 230 | if ( empty( $post_type ) ) { |
|
| 231 | return true; |
|
| 232 | } |
|
| 233 | ||
| 234 | // allow special 'any' type |
|
| 235 | if ( 'any' == $post_type ) { |
|
| 236 | return true; |
|
| 237 | } |
|
| 238 | ||
| 239 | // check for allowed types |
|
| 240 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
| 241 | return true; |
|
| 242 | } |
|
| 243 | ||
| 244 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 245 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 246 | return $post_type_object->show_in_rest; |
|
| 247 | } |
|
| 248 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 249 | return $post_type_object->publicly_queryable; |
|
| 250 | } |
|
| 251 | } |
|
| 252 | ||
| 253 | return ! empty( $post_type_object->public ); |
|
| 254 | } |
|
| 255 | ||
| 256 | // copied from class.json-api-endpoints.php |
|
| 257 | /** |
|