WP_REST_Menu_Items_Controller::prepare_items_query() – Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.

You appear to be a bot. Output may be restricted

Description

Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.

Usage

$array = WP_REST_Menu_Items_Controller::prepare_items_query( $prepared_args, $request );

Parameters

$prepared_args
( array ) optional – Optional. Prepared WP_Query arguments. Default empty array.
$request
( WP_REST_Request ) optional – Optional. Full details about the request.

Returns

array Items query arguments.

Source

File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php


Lines:

1 to 21 of 21
  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;
  }
 

 View on GitHub View on Trac