[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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: 403 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

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


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.


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


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

param: WP_REST_Request $request Full details about the request.
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.
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 block pattern before it gets output in a REST API response.

param: object          $item    Raw pattern from api.wordpress.org, before any changes.
param: WP_REST_Request $request Request object.
return: WP_REST_Response

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

return: array Item schema data.

get_collection_params()   X-Ref
Retrieves the search parameters for the block pattern's collection.

return: array Collection parameters.

get_transient_key( $query_args )   X-Ref
Include a hash of the query args, so that different requests are stored in
separate caches.

MD5 is chosen for its speed, low-collision rate, universal availability, and to stay
under the character limit for `_site_transient_timeout_{...}` keys.

param: array $query_args Query arguments to generate a transient key from.
return: string Transient key.



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref