@@ 208-234 (lines=27) @@ | ||
205 | } |
|
206 | ||
207 | // copied from class.json-api-endpoints.php |
|
208 | public function is_post_type_allowed( $post_type ) { |
|
209 | // if the post type is empty, that's fine, WordPress will default to post |
|
210 | if ( empty( $post_type ) ) { |
|
211 | return true; |
|
212 | } |
|
213 | ||
214 | // allow special 'any' type |
|
215 | if ( 'any' == $post_type ) { |
|
216 | return true; |
|
217 | } |
|
218 | ||
219 | // check for allowed types |
|
220 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
221 | return true; |
|
222 | } |
|
223 | ||
224 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
225 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
226 | return $post_type_object->show_in_rest; |
|
227 | } |
|
228 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
229 | return $post_type_object->publicly_queryable; |
|
230 | } |
|
231 | } |
|
232 | ||
233 | return ! empty( $post_type_object->public ); |
|
234 | } |
|
235 | ||
236 | // copied from class.json-api-endpoints.php |
|
237 | /** |
@@ 1692-1718 (lines=27) @@ | ||
1689 | } |
|
1690 | } |
|
1691 | ||
1692 | function is_post_type_allowed( $post_type ) { |
|
1693 | // if the post type is empty, that's fine, WordPress will default to post |
|
1694 | if ( empty( $post_type ) ) { |
|
1695 | return true; |
|
1696 | } |
|
1697 | ||
1698 | // allow special 'any' type |
|
1699 | if ( 'any' == $post_type ) { |
|
1700 | return true; |
|
1701 | } |
|
1702 | ||
1703 | // check for allowed types |
|
1704 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
1705 | return true; |
|
1706 | } |
|
1707 | ||
1708 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
1709 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
1710 | return $post_type_object->show_in_rest; |
|
1711 | } |
|
1712 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
1713 | return $post_type_object->publicly_queryable; |
|
1714 | } |
|
1715 | } |
|
1716 | ||
1717 | return ! empty( $post_type_object->public ); |
|
1718 | } |
|
1719 | ||
1720 | /** |
|
1721 | * Gets the whitelisted post types that JP should allow access to. |