WP_REST_Menus_Controller::prepare_item_for_database() WordPress Method
The WP_REST_Menus_Controller::prepare_item_for_database() method is used to prepare a menu item for database insertion or update. This method sanitizes the menu item data and sets any missing default values.
WP_REST_Menus_Controller::prepare_item_for_database( WP_REST_Request $request ) #
Prepares a single term for create or update.
Parameters
- $request
(WP_REST_Request)(Required)Request object.
Return
(object) Prepared term data.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php
public function prepare_item_for_database( $request ) { $prepared_term = parent::prepare_item_for_database( $request ); $schema = $this->get_item_schema(); if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) { $prepared_term->{'menu-name'} = $request['name']; } return $prepared_term; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.9.0 | Introduced. |