CoreFiles by mySites.guru
navigation-fallback.php41 lines, 1,718 bytes, from wordpress-6.3-beta1.zip
Raw History Compare with 6.2-beta5
md5
cdd7408d29e47491d754df2143900fda
sha1
a81ae40a78112ef61137b64f5e85665c6650a9dd
sha256
27fbf2c9ac42a6ef69912a360dd99ef40f65180375703dcff22b8cd69e7eacfd
<?php
/**
 * Navigation Fallback
 *
 * Functions required for managing Navigation fallbacks behavior.
 *
 * @package WordPress
 * @since 6.3.0
 */

/**
 * Expose additional fields in the embeddable links of the
 * 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.
 *
 * @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 ) {
	// 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.
	$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' ) );

	return $schema;
}

add_filter(
	'rest_wp_navigation_item_schema',
	'wp_add_fields_to_navigation_fallback_embeded_links'
);

The same content is in 5 releases, WordPress 6.3-beta1 to 6.3-RC1. See them all, or every version of this file.