[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/rest-api/endpoints/ -> class-wp-rest-pattern-directory-controller.php (summary)

Block Pattern Directory REST API: WP_REST_Pattern_Directory_Controller class

File Size: 347 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_REST_Pattern_Directory_Controller:: (7 methods):
  __construct()
  register_routes()
  get_items_permissions_check()
  get_items()
  prepare_item_for_response()
  get_item_schema()
  get_collection_params()


Class: WP_REST_Pattern_Directory_Controller  - X-Ref

Controller which provides REST endpoint for block patterns.

This simply proxies the endpoint at http://api.wordpress.org/patterns/1.0/. That isn't necessary for
functionality, but is desired for privacy. It prevents api.wordpress.org from knowing the user's IP address.

__construct()   X-Ref
Constructs the controller.

since: 5.8.0

register_routes()   X-Ref
Registers the necessary REST API routes.

since: 5.8.0

get_items_permissions_check( $request )   X-Ref
Checks whether a given request has permission to view the local pattern directory.

param: WP_REST_Request $request Full details about the request.
since: 5.8.0
return: true|WP_Error True if the request has permission, WP_Error object otherwise.

get_items( $request )   X-Ref
Search and retrieve block patterns metadata

param: WP_REST_Request $request Full details about the request.
since: 5.8.0
return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

prepare_item_for_response( $item, $request )   X-Ref
Prepare a raw pattern before it's output in an API response.

param: object          $item    Raw pattern from api.wordpress.org, before any changes.
param: WP_REST_Request $request Request object.
since: 5.8.0
since: 5.9.0 Renamed `$raw_pattern` to `$item` to match parent class for PHP 8 named parameter support.
return: WP_REST_Response

get_item_schema()   X-Ref
Retrieves the pattern's schema, conforming to JSON Schema.

since: 5.8.0
return: array Item schema data.

get_collection_params()   X-Ref
Retrieves the search params for the patterns collection.

since: 5.8.0
return: array Collection parameters.



Generated: Mon Sep 20 01:00:04 2021 Cross-referenced by PHPXref 0.7.1