@@ 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 | /** |
@@ 1770-1796 (lines=27) @@ | ||
1767 | } |
|
1768 | } |
|
1769 | ||
1770 | function is_post_type_allowed( $post_type ) { |
|
1771 | // if the post type is empty, that's fine, WordPress will default to post |
|
1772 | if ( empty( $post_type ) ) { |
|
1773 | return true; |
|
1774 | } |
|
1775 | ||
1776 | // allow special 'any' type |
|
1777 | if ( 'any' == $post_type ) { |
|
1778 | return true; |
|
1779 | } |
|
1780 | ||
1781 | // check for allowed types |
|
1782 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
1783 | return true; |
|
1784 | } |
|
1785 | ||
1786 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
1787 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
1788 | return $post_type_object->show_in_rest; |
|
1789 | } |
|
1790 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
1791 | return $post_type_object->publicly_queryable; |
|
1792 | } |
|
1793 | } |
|
1794 | ||
1795 | return ! empty( $post_type_object->public ); |
|
1796 | } |
|
1797 | ||
1798 | /** |
|
1799 | * Gets the whitelisted post types that JP should allow access to. |