@@ 1666-1692 (lines=27) @@ | ||
1663 | } |
|
1664 | } |
|
1665 | ||
1666 | function is_post_type_allowed( $post_type ) { |
|
1667 | // if the post type is empty, that's fine, WordPress will default to post |
|
1668 | if ( empty( $post_type ) ) { |
|
1669 | return true; |
|
1670 | } |
|
1671 | ||
1672 | // allow special 'any' type |
|
1673 | if ( 'any' == $post_type ) { |
|
1674 | return true; |
|
1675 | } |
|
1676 | ||
1677 | // check for allowed types |
|
1678 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
1679 | return true; |
|
1680 | } |
|
1681 | ||
1682 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
1683 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
1684 | return $post_type_object->show_in_rest; |
|
1685 | } |
|
1686 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
1687 | return $post_type_object->publicly_queryable; |
|
1688 | } |
|
1689 | } |
|
1690 | ||
1691 | return ! empty( $post_type_object->public ); |
|
1692 | } |
|
1693 | ||
1694 | /** |
|
1695 | * Gets the whitelisted post types that JP should allow access to. |
@@ 194-220 (lines=27) @@ | ||
191 | } |
|
192 | ||
193 | // copied from class.json-api-endpoints.php |
|
194 | public function is_post_type_allowed( $post_type ) { |
|
195 | // if the post type is empty, that's fine, WordPress will default to post |
|
196 | if ( empty( $post_type ) ) { |
|
197 | return true; |
|
198 | } |
|
199 | ||
200 | // allow special 'any' type |
|
201 | if ( 'any' == $post_type ) { |
|
202 | return true; |
|
203 | } |
|
204 | ||
205 | // check for allowed types |
|
206 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
207 | return true; |
|
208 | } |
|
209 | ||
210 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
211 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
212 | return $post_type_object->show_in_rest; |
|
213 | } |
|
214 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
215 | return $post_type_object->publicly_queryable; |
|
216 | } |
|
217 | } |
|
218 | ||
219 | return ! empty( $post_type_object->public ); |
|
220 | } |
|
221 | ||
222 | // copied from class.json-api-endpoints.php |
|
223 | /** |