| @@ 263-289 (lines=27) @@ | ||
| 260 | } |
|
| 261 | ||
| 262 | // copied from class.json-api-endpoints.php |
|
| 263 | public function is_post_type_allowed( $post_type ) { |
|
| 264 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 265 | if ( empty( $post_type ) ) { |
|
| 266 | return true; |
|
| 267 | } |
|
| 268 | ||
| 269 | // allow special 'any' type |
|
| 270 | if ( 'any' == $post_type ) { |
|
| 271 | return true; |
|
| 272 | } |
|
| 273 | ||
| 274 | // check for allowed types |
|
| 275 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
| 276 | return true; |
|
| 277 | } |
|
| 278 | ||
| 279 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 280 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 281 | return $post_type_object->show_in_rest; |
|
| 282 | } |
|
| 283 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 284 | return $post_type_object->publicly_queryable; |
|
| 285 | } |
|
| 286 | } |
|
| 287 | ||
| 288 | return ! empty( $post_type_object->public ); |
|
| 289 | } |
|
| 290 | ||
| 291 | // copied from class.json-api-endpoints.php |
|
| 292 | /** |
|
| @@ 1782-1808 (lines=27) @@ | ||
| 1779 | } |
|
| 1780 | } |
|
| 1781 | ||
| 1782 | function is_post_type_allowed( $post_type ) { |
|
| 1783 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 1784 | if ( empty( $post_type ) ) { |
|
| 1785 | return true; |
|
| 1786 | } |
|
| 1787 | ||
| 1788 | // allow special 'any' type |
|
| 1789 | if ( 'any' == $post_type ) { |
|
| 1790 | return true; |
|
| 1791 | } |
|
| 1792 | ||
| 1793 | // check for allowed types |
|
| 1794 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
| 1795 | return true; |
|
| 1796 | } |
|
| 1797 | ||
| 1798 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 1799 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 1800 | return $post_type_object->show_in_rest; |
|
| 1801 | } |
|
| 1802 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 1803 | return $post_type_object->publicly_queryable; |
|
| 1804 | } |
|
| 1805 | } |
|
| 1806 | ||
| 1807 | return ! empty( $post_type_object->public ); |
|
| 1808 | } |
|
| 1809 | ||
| 1810 | /** |
|
| 1811 | * Gets the whitelisted post types that JP should allow access to. |
|