WP_REST_Menus_Controller::get_item_schema() – Retrieves the term’s schema, conforming to JSON Schema.

You appear to be a bot. Output may be restricted

Description

Retrieves the term's schema, conforming to JSON Schema.

Usage

$array = WP_REST_Menus_Controller::get_item_schema();

Parameters

Returns

array Item schema data.

Source

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


Lines:

1 to 47 of 47
  public function get_item_schema() {
    $schema = parent::get_item_schema();
    unset( $schema['properties']['count'], $schema['properties']['link'], $schema['properties']['taxonomy'] );

    $schema['properties']['locations'] = array(
      'description' => __( 'The locations assigned to the menu.' ),
      'type'        => 'array',
      'items'       => array(
        'type' => 'string',
      ),
      'context'     => array( 'view', 'edit' ),
      'arg_options' => array(
        'validate_callback' => function ( $locations, $request, $param ) {
          $valid = rest_validate_request_arg( $locations, $request, $param );

          if ( true !== $valid ) {
            return $valid;
          }

          $locations = rest_sanitize_request_arg( $locations, $request, $param );

          foreach ( $locations as $location ) {
            if ( ! array_key_exists( $location, get_registered_nav_menus() ) ) {
              return new WP_Error(
                'rest_invalid_menu_location',
                __( 'Invalid menu location.' ),
                array(
                  'location' => $location,
                )
              );
            }
          }

          return true;
        },
      ),
    );

    $schema['properties']['auto_add'] = array(
      'description' => __( 'Whether to automatically add top level pages to this menu.' ),
      'context'     => array( 'view', 'edit' ),
      'type'        => 'boolean',
    );

    return $schema;
  }
 

 View on GitHub View on Trac