WP_Navigation_Fallback::update_wp_navigation_post_schema
Updates the wp_navigation custom post type schema, in order to expose additional fields in the embeddable links of WP_REST_Navigation_Fallback_Controller.
The Navigation Fallback endpoint may embed the full Navigation Menu object into the 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.
Used with the rest_wp_navigation_item_schema hook.
Метод класса: WP_Navigation_Fallback{}
Хуков нет.
Возвращает
Массив. The modified schema.
Использование
$result = WP_Navigation_Fallback::update_wp_navigation_post_schema( $schema );
- $schema(массив) (обязательный)
- The schema for the
wp_navigationpost.
Список изменений
| С версии 6.4.0 | Введена. |
Код WP_Navigation_Fallback::update_wp_navigation_post_schema() WP Navigation Fallback::update wp navigation post schema WP 6.9.1
public static function update_wp_navigation_post_schema( $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' ) );
/*
* 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;
}