Changeset 56297 for branches/6.3
- Timestamp:
- 07/25/2023 06:33:12 AM (17 months ago)
- Location:
- branches/6.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.3
-
branches/6.3/src/wp-includes/navigation-fallback.php
r56052 r56297 14 14 * 15 15 * The endpoint may embed the full Navigation Menu object into the 16 * response as the `self` link. By default the Posts Controller17 * will only expose sa limited subset of fields but the editor requires18 * additional fields to be available in order to utili se the menu.16 * response as the `self` link. By default, the Posts Controller 17 * will only expose a limited subset of fields but the editor requires 18 * additional fields to be available in order to utilize the menu. 19 19 * 20 20 * @since 6.3.0 … … 23 23 * @return array the modified schema. 24 24 */ 25 function wp_add_fields_to_navigation_fallback_embed ed_links( $schema ) {25 function wp_add_fields_to_navigation_fallback_embedded_links( $schema ) { 26 26 // Expose top level fields. 27 27 $schema['properties']['status']['context'] = array_merge( $schema['properties']['status']['context'], array( 'embed' ) ); 28 28 $schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) ); 29 29 30 // Expose sub properties of content field. 30 /* 31 * Exposes sub properties of content field. 32 * These sub properties aren't exposed by the posts controller by default, 33 * for requests where context is `embed`. 34 * 35 * @see WP_REST_Posts_Controller::get_item_schema() 36 */ 31 37 $schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) ); 32 38 $schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) ); 33 39 $schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) ); 40 41 /* 42 * Exposes sub properties of title field. 43 * These sub properties aren't exposed by the posts controller by default, 44 * for requests where context is `embed`. 45 * 46 * @see WP_REST_Posts_Controller::get_item_schema() 47 */ 48 $schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) ); 34 49 35 50 return $schema; … … 38 53 add_filter( 39 54 'rest_wp_navigation_item_schema', 40 'wp_add_fields_to_navigation_fallback_embed ed_links'55 'wp_add_fields_to_navigation_fallback_embedded_links' 41 56 ); -
branches/6.3/src/wp-settings.php
r56241 r56297 348 348 require ABSPATH . WPINC . '/block-supports/typography.php'; 349 349 require ABSPATH . WPINC . '/block-supports/settings.php'; 350 require ABSPATH . WPINC . '/navigation-fallback.php'; 350 351 require ABSPATH . WPINC . '/style-engine.php'; 351 352 require ABSPATH . WPINC . '/style-engine/class-wp-style-engine.php'; -
branches/6.3/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php
r56052 r56297 142 142 143 143 $this->assertTrue( $links['self'][0]['attributes']['embeddable'], 'Self link should be embeddable.' ); 144 } 145 146 /** 147 * Tests that the correct filters are applied to the context parameter. 148 * 149 * By default, the REST response for the Posts Controller will not return all fields 150 * when the context is set to 'embed'. Assert that correct additional fields are added 151 * to the embedded Navigation Post, when the navigation fallback endpoint 152 * is called with the `_embed` param. 153 * 154 * @ticket 58557 155 * 156 * @covers wp_add_fields_to_navigation_fallback_embedded_links 157 * 158 * @since 6.3.0 Added Navigation Fallbacks endpoint. 159 */ 160 public function test_embedded_navigation_post_contains_required_fields() { 161 // First we'll use the navigation fallback to get a link to the navigation endpoint. 162 $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); 163 $response = rest_get_server()->dispatch( $request ); 164 $links = $response->get_links(); 165 166 // Extract the navigation endpoint URL from the response. 167 $embedded_navigation_href = $links['self'][0]['href']; 168 preg_match( '/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); 169 $navigation_endpoint = $matches[1]; 170 171 // Fetch the "linked" navigation post from the endpoint, with the context parameter set to 'embed' to simulate fetching embedded links. 172 $request = new WP_REST_Request( 'GET', $navigation_endpoint ); 173 $request->set_param( 'context', 'embed' ); 174 $response = rest_get_server()->dispatch( $request ); 175 $data = $response->get_data(); 176 177 // Verify that the additional status field is present. 178 $this->assertArrayHasKey( 'status', $data, 'Response title should contain a "status" field.' ); 179 180 // Verify that the additional content fields are present. 181 $this->assertArrayHasKey( 'content', $data, 'Response should contain a "content" field.' ); 182 $this->assertArrayHasKey( 'raw', $data['content'], 'Response content should contain a "raw" field.' ); 183 $this->assertArrayHasKey( 'rendered', $data['content'], 'Response content should contain a "rendered" field.' ); 184 $this->assertArrayHasKey( 'block_version', $data['content'], 'Response should contain a "block_version" field.' ); 185 186 // Verify that the additional title.raw field is present. 187 $this->assertArrayHasKey( 'raw', $data['title'], 'Response title should contain a "raw" key.' ); 144 188 } 145 189 -
branches/6.3/tests/qunit/fixtures/wp-api-generated.js
r56082 r56297 6683 6683 "type": "string", 6684 6684 "context": [ 6685 "edit" 6685 "edit", 6686 "embed" 6686 6687 ] 6687 6688 }, … … 6707 6708 "type": "string", 6708 6709 "context": [ 6709 "edit" 6710 "edit", 6711 "embed" 6710 6712 ] 6711 6713 }, … … 6715 6717 "context": [ 6716 6718 "view", 6717 "edit" 6719 "edit", 6720 "embed" 6718 6721 ], 6719 6722 "readonly": true … … 6723 6726 "type": "integer", 6724 6727 "context": [ 6725 "edit" 6728 "edit", 6729 "embed" 6726 6730 ], 6727 6731 "readonly": true … … 6860 6864 "type": "string", 6861 6865 "context": [ 6862 "edit" 6866 "edit", 6867 "embed" 6863 6868 ] 6864 6869 }, … … 6884 6889 "type": "string", 6885 6890 "context": [ 6886 "edit" 6891 "edit", 6892 "embed" 6887 6893 ] 6888 6894 }, … … 6892 6898 "context": [ 6893 6899 "view", 6894 "edit" 6900 "edit", 6901 "embed" 6895 6902 ], 6896 6903 "readonly": true … … 6900 6907 "type": "integer", 6901 6908 "context": [ 6902 "edit" 6909 "edit", 6910 "embed" 6903 6911 ], 6904 6912 "readonly": true … … 7193 7201 "type": "string", 7194 7202 "context": [ 7195 "edit" 7203 "edit", 7204 "embed" 7196 7205 ] 7197 7206 }, … … 7217 7226 "type": "string", 7218 7227 "context": [ 7219 "edit" 7228 "edit", 7229 "embed" 7220 7230 ] 7221 7231 }, … … 7225 7235 "context": [ 7226 7236 "view", 7227 "edit" 7237 "edit", 7238 "embed" 7228 7239 ], 7229 7240 "readonly": true … … 7233 7244 "type": "integer", 7234 7245 "context": [ 7235 "edit" 7246 "edit", 7247 "embed" 7236 7248 ], 7237 7249 "readonly": true
Note: See TracChangeset
for help on using the changeset viewer.