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