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