| @@ 1729-1755 (lines=27) @@ | ||
| 1726 | } |
|
| 1727 | } |
|
| 1728 | ||
| 1729 | function is_post_type_allowed( $post_type ) { |
|
| 1730 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 1731 | if ( empty( $post_type ) ) { |
|
| 1732 | return true; |
|
| 1733 | } |
|
| 1734 | ||
| 1735 | // allow special 'any' type |
|
| 1736 | if ( 'any' == $post_type ) { |
|
| 1737 | return true; |
|
| 1738 | } |
|
| 1739 | ||
| 1740 | // check for allowed types |
|
| 1741 | if ( in_array( $post_type, $this->_get_whitelisted_post_types() ) ) { |
|
| 1742 | return true; |
|
| 1743 | } |
|
| 1744 | ||
| 1745 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 1746 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 1747 | return $post_type_object->show_in_rest; |
|
| 1748 | } |
|
| 1749 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 1750 | return $post_type_object->publicly_queryable; |
|
| 1751 | } |
|
| 1752 | } |
|
| 1753 | ||
| 1754 | return ! empty( $post_type_object->public ); |
|
| 1755 | } |
|
| 1756 | ||
| 1757 | /** |
|
| 1758 | * Gets the whitelisted post types that JP should allow access to. |
|
| @@ 218-244 (lines=27) @@ | ||
| 215 | } |
|
| 216 | ||
| 217 | // copied from class.json-api-endpoints.php |
|
| 218 | public function is_post_type_allowed( $post_type ) { |
|
| 219 | // if the post type is empty, that's fine, WordPress will default to post |
|
| 220 | if ( empty( $post_type ) ) { |
|
| 221 | return true; |
|
| 222 | } |
|
| 223 | ||
| 224 | // allow special 'any' type |
|
| 225 | if ( 'any' == $post_type ) { |
|
| 226 | return true; |
|
| 227 | } |
|
| 228 | ||
| 229 | // check for allowed types |
|
| 230 | if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) { |
|
| 231 | return true; |
|
| 232 | } |
|
| 233 | ||
| 234 | if ( $post_type_object = get_post_type_object( $post_type ) ) { |
|
| 235 | if ( ! empty( $post_type_object->show_in_rest ) ) { |
|
| 236 | return $post_type_object->show_in_rest; |
|
| 237 | } |
|
| 238 | if ( ! empty( $post_type_object->publicly_queryable ) ) { |
|
| 239 | return $post_type_object->publicly_queryable; |
|
| 240 | } |
|
| 241 | } |
|
| 242 | ||
| 243 | return ! empty( $post_type_object->public ); |
|
| 244 | } |
|
| 245 | ||
| 246 | // copied from class.json-api-endpoints.php |
|
| 247 | /** |
|