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.


Top ↑

Return

(object) Prepared term data.


Top ↑

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;
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.