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