| @@ 1759-1785 (lines=27) @@ | ||
| 1756 | } |
|
| 1757 | } |
|
| 1758 | ||
| 1759 | function is_post_type_allowed( $post_type ) { |
|
| 1760 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 1761 | if ( empty( $post_type ) ) { |
|
| 1762 | return true; |
|
| 1763 | } |
|
| 1764 | ||
| 1765 | // allow special 'any' type |
|
| 1766 | if ( 'any' == $post_type ) { |
|
| 1767 | return true; |
|
| 1768 | } |
|
| 1769 | ||
| 1770 | // check for allowed types |
|
| 1771 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
| 1772 | return true; |
|
| 1773 | } |
|
| 1774 | ||
| 1775 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 1776 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 1777 | return $post_type_object->show_in_rest; |
|
| 1778 | } |
|
| 1779 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 1780 | return $post_type_object->publicly_queryable; |
|
| 1781 | } |
|
| 1782 | } |
|
| 1783 | ||
| 1784 | return ! empty( $post_type_object->public ); |
|
| 1785 | } |
|
| 1786 | ||
| 1787 | /** |
|
| 1788 | * Gets the whitelisted post types that JP should allow access to. |
|
| @@ 249-275 (lines=27) @@ | ||
| 246 | } |
|
| 247 | ||
| 248 | // copied from class.json-api-endpoints.php |
|
| 249 | public function is_post_type_allowed( $post_type ) { |
|
| 250 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 251 | if ( empty( $post_type ) ) { |
|
| 252 | return true; |
|
| 253 | } |
|
| 254 | ||
| 255 | // allow special 'any' type |
|
| 256 | if ( 'any' == $post_type ) { |
|
| 257 | return true; |
|
| 258 | } |
|
| 259 | ||
| 260 | // check for allowed types |
|
| 261 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
| 262 | return true; |
|
| 263 | } |
|
| 264 | ||
| 265 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 266 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 267 | return $post_type_object->show_in_rest; |
|
| 268 | } |
|
| 269 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 270 | return $post_type_object->publicly_queryable; |
|
| 271 | } |
|
| 272 | } |
|
| 273 | ||
| 274 | return ! empty( $post_type_object->public ); |
|
| 275 | } |
|
| 276 | ||
| 277 | // copied from class.json-api-endpoints.php |
|
| 278 | /** |
|