| @@ 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. |
|
| @@ 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 | /** |
|