Editor: load title on navigation fallback.

Adds raw title property when loading the navigation fallback with an embed context.

Props ramonopoly, get_dave, scruffian, mukesh27, audrasjb.
Reviewed by audrasjb.
Merges [56296] to the 6.3 branch.
See #58557.

Built from https://develop.svn.wordpress.org/branches/6.3@56297


git-svn-id: http://core.svn.wordpress.org/branches/6.3@55809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
isabel_brison 2023-07-25 06:35:23 +00:00
parent 62f019bc23
commit d09c4a36a7
3 changed files with 23 additions and 7 deletions

View File

@ -13,29 +13,44 @@
* Navigation Fallback REST endpoint.
*
* The endpoint may embed the full Navigation Menu object into the
* response as the `self` link. By default the Posts Controller
* will only exposes a limited subset of fields but the editor requires
* additional fields to be available in order to utilise the menu.
* response as the `self` link. By default, the Posts Controller
* will only expose a limited subset of fields but the editor requires
* additional fields to be available in order to utilize the menu.
*
* @since 6.3.0
*
* @param array $schema the schema for the `wp_navigation` post.
* @return array the modified schema.
*/
function wp_add_fields_to_navigation_fallback_embeded_links( $schema ) {
function wp_add_fields_to_navigation_fallback_embedded_links( $schema ) {
// Expose top level fields.
$schema['properties']['status']['context'] = array_merge( $schema['properties']['status']['context'], array( 'embed' ) );
$schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) );
// Expose sub properties of content field.
/*
* Exposes sub properties of content field.
* These sub properties aren't exposed by the posts controller by default,
* for requests where context is `embed`.
*
* @see WP_REST_Posts_Controller::get_item_schema()
*/
$schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) );
/*
* Exposes sub properties of title field.
* These sub properties aren't exposed by the posts controller by default,
* for requests where context is `embed`.
*
* @see WP_REST_Posts_Controller::get_item_schema()
*/
$schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) );
return $schema;
}
add_filter(
'rest_wp_navigation_item_schema',
'wp_add_fields_to_navigation_fallback_embeded_links'
'wp_add_fields_to_navigation_fallback_embedded_links'
);

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-RC1-56295';
$wp_version = '6.3-RC1-56297';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -347,6 +347,7 @@ require ABSPATH . WPINC . '/block-supports/position.php';
require ABSPATH . WPINC . '/block-supports/spacing.php';
require ABSPATH . WPINC . '/block-supports/typography.php';
require ABSPATH . WPINC . '/block-supports/settings.php';
require ABSPATH . WPINC . '/navigation-fallback.php';
require ABSPATH . WPINC . '/style-engine.php';
require ABSPATH . WPINC . '/style-engine/class-wp-style-engine.php';
require ABSPATH . WPINC . '/style-engine/class-wp-style-engine-css-declarations.php';