@@ 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 | /** |
@@ 1675-1701 (lines=27) @@ | ||
1672 | } |
|
1673 | } |
|
1674 | ||
1675 | function is_post_type_allowed( $post_type ) { |
|
1676 | // if the post type is empty, that's fine, WordPress will default to post |
|
1677 | if ( empty( $post_type ) ) { |
|
1678 | return true; |
|
1679 | } |
|
1680 | ||
1681 | // allow special 'any' type |
|
1682 | if ( 'any' == $post_type ) { |
|
1683 | return true; |
|
1684 | } |
|
1685 | ||
1686 | // check for allowed types |
|
1687 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
1688 | return true; |
|
1689 | } |
|
1690 | ||
1691 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
1692 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
1693 | return $post_type_object->show_in_rest; |
|
1694 | } |
|
1695 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
1696 | return $post_type_object->publicly_queryable; |
|
1697 | } |
|
1698 | } |
|
1699 | ||
1700 | return ! empty( $post_type_object->public ); |
|
1701 | } |
|
1702 | ||
1703 | /** |
|
1704 | * Gets the whitelisted post types that JP should allow access to. |