WP_REST_Menu_Items_Controller::prepare_items_query()protectedWP 5.9.0

them for WP_Query.

{} It's a method of the class: WP_REST_Menu_Items_Controller{}

No Hooks.

Return

Array. Items query arguments.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_items_query( $prepared_args, $request );
$prepared_args(array)
Prepared WP_Query arguments.
Default: empty array
$request(WP_REST_Request)
Full details about the request.
Default: null

Changelog

Since 5.9.0 Introduced.

Code of WP_REST_Menu_Items_Controller::prepare_items_query() WP 6.0

protected function prepare_items_query( $prepared_args = array(), $request = null ) {
	$query_args = parent::prepare_items_query( $prepared_args, $request );

	// Map to proper WP_Query orderby param.
	if ( isset( $query_args['orderby'], $request['orderby'] ) ) {
		$orderby_mappings = array(
			'id'            => 'ID',
			'include'       => 'post__in',
			'slug'          => 'post_name',
			'include_slugs' => 'post_name__in',
			'menu_order'    => 'menu_order',
		);

		if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) {
			$query_args['orderby'] = $orderby_mappings[ $request['orderby'] ];
		}
	}

	return $query_args;
}