Make WordPress Core


Ignore:
Timestamp:
07/25/2023 06:28:28 AM (3 years ago)
Author:
isabel_brison
Message:

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.
Fixes #58557.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/navigation-fallback.php

    r56052 r56296  
    1414 *
    1515 * The endpoint may embed the full Navigation Menu object into the
    16  * response as the `self` link. By default the Posts Controller
    17  * will only exposes a limited subset of fields but the editor requires
    18  * additional fields to be available in order to utilise 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.
    1919 *
    2020 * @since 6.3.0
     
    2323 * @return array the modified schema.
    2424 */
    25 function wp_add_fields_to_navigation_fallback_embeded_links( $schema ) {
     25function wp_add_fields_to_navigation_fallback_embedded_links( $schema ) {
    2626    // Expose top level fields.
    2727    $schema['properties']['status']['context']  = array_merge( $schema['properties']['status']['context'], array( 'embed' ) );
    2828    $schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) );
    2929
    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     */
    3137    $schema['properties']['content']['properties']['raw']['context']           = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) );
    3238    $schema['properties']['content']['properties']['rendered']['context']      = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) );
    3339    $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' ) );
    3449
    3550    return $schema;
     
    3853add_filter(
    3954    'rest_wp_navigation_item_schema',
    40     'wp_add_fields_to_navigation_fallback_embeded_links'
     55    'wp_add_fields_to_navigation_fallback_embedded_links'
    4156);
Note: See TracChangeset for help on using the changeset viewer.