diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index e53ff4b910..614340f089 100644
a
|
b
|
class WP_REST_Posts_Controller extends WP_REST_Controller { |
2035 | 2035 | ), |
2036 | 2036 | ); |
2037 | 2037 | foreach ( $post_type_attributes as $attribute ) { |
2038 | | if ( isset( $fixed_schemas[ $this->post_type ] ) && ! in_array( $attribute, $fixed_schemas[ $this->post_type ], true ) ) { |
2039 | | continue; |
2040 | | } elseif ( ! isset( $fixed_schemas[ $this->post_type ] ) && ! post_type_supports( $this->post_type, $attribute ) ) { |
2041 | | continue; |
2042 | | } |
| 2038 | if ( |
| 2039 | ( ! isset( $fixed_schemas[ $this->post_type ] ) ) || |
| 2040 | ( |
| 2041 | isset( $fixed_schemas[ $this->post_type ] ) && |
| 2042 | ! in_array( $attribute, $fixed_schemas[ $this->post_type ], true ) |
| 2043 | ) |
| 2044 | ) { |
| 2045 | if ( ! post_type_supports( $this->post_type, $attribute ) ) { |
| 2046 | continue; |
| 2047 | } |
| 2048 | } |
2043 | 2049 | |
2044 | 2050 | switch ( $attribute ) { |
2045 | 2051 | |
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index ba174c448e..e0b11ecec0 100644
a
|
b
|
class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te |
3591 | 3591 | $this->assertArrayHasKey( 'categories', $properties ); |
3592 | 3592 | } |
3593 | 3593 | |
| 3594 | public function test_add_post_type_supports_adds_entries_to_schema() { |
| 3595 | add_post_type_support('post', 'page-attributes'); |
| 3596 | create_initial_rest_routes(); |
| 3597 | $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); |
| 3598 | $response = rest_get_server()->dispatch( $request ); |
| 3599 | $data = $response->get_data(); |
| 3600 | $properties = $data['schema']['properties']; |
| 3601 | $this->assertArrayHasKey( 'menu_order', $properties ); |
| 3602 | } |
| 3603 | |
3594 | 3604 | /** |
3595 | 3605 | * @ticket 39805 |
3596 | 3606 | */ |