PHP Класс WP_REST_Attachments_Controller, wordpress

Наследование: extends WP_REST_Posts_Controller
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Creates a single attachment.
create_item_permissions_check ( WP_REST_Request $request ) : WP_Error | true Checks if a given request has access to create an attachment.
get_collection_params ( ) : array Retrieves the query params for collections of attachments.
get_filename_from_disposition ( string[] $disposition_header ) : string | null Parses filename from a Content-Disposition header value.
get_item_schema ( ) : array Retrieves the attachment's schema, conforming to JSON Schema.
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response Prepares a single attachment output for response.
update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Updates a single attachment.
validate_user_can_query_private_statuses ( mixed $value, WP_REST_Request $request, string $parameter ) : WP_Error | boolean Validates whether the user can query private statuses.

Защищенные методы

Метод Описание
get_media_types ( ) : array Retrieves the supported media types.
prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass Prepares a single attachment for create or update.
prepare_items_query ( array $prepared_args = [], WP_REST_Request $request = null ) : array Determines the allowed query_vars for a get_items() response and prepares for WP_Query.
upload_from_data ( array $data, array $headers ) : array | WP_Error Handles an upload via raw POST data.
upload_from_file ( array $files, array $headers ) : array | WP_Error Handles an upload via multipart/form-data ($_FILES).

Описание методов

create_item() публичный Метод

Creates a single attachment.
С версии: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, WP_Error object on failure.

create_item_permissions_check() публичный Метод

Checks if a given request has access to create an attachment.
С версии: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : WP_Error | true
$request WP_REST_Request Full details about the request.
Результат WP_Error | true Boolean true if the attachment may be created, or a WP_Error if not.

get_collection_params() публичный Метод

Retrieves the query params for collections of attachments.
С версии: 4.7.0
public get_collection_params ( ) : array
Результат array Query parameters for the attachment collection as an array.

get_filename_from_disposition() публичный статический Метод

As per RFC6266: content-disposition = "Content-Disposition" ":" disposition-type *( ";" disposition-parm ) disposition-type = "inline" | "attachment" | disp-ext-type ; case-insensitive disp-ext-type = token disposition-parm = filename-parm | disp-ext-parm filename-parm = "filename" "=" value | "filename*" "=" ext-value disp-ext-parm = token "=" value | ext-token "=" ext-value ext-token =
С версии: 4.7.0
public static get_filename_from_disposition ( string[] $disposition_header ) : string | null
$disposition_header string[] List of Content-Disposition header values.
Результат string | null Filename if available, or null if not found.

get_item_schema() публичный Метод

Retrieves the attachment's schema, conforming to JSON Schema.
С версии: 4.7.0
public get_item_schema ( ) : array
Результат array Item schema as an array.

get_media_types() защищенный Метод

Media types are considered the MIME type category.
С версии: 4.7.0
protected get_media_types ( ) : array
Результат array Array of supported media types.

prepare_item_for_database() защищенный Метод

Prepares a single attachment for create or update.
С версии: 4.7.0
protected prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass
$request WP_REST_Request Request object.
Результат WP_Error | stdClass $prepared_attachment Post object.

prepare_item_for_response() публичный Метод

Prepares a single attachment output for response.
С версии: 4.7.0
public prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response
$post WP_Post Attachment object.
$request WP_REST_Request Request object.
Результат WP_REST_Response Response object.

prepare_items_query() защищенный Метод

Determines the allowed query_vars for a get_items() response and prepares for WP_Query.
С версии: 4.7.0
protected prepare_items_query ( array $prepared_args = [], WP_REST_Request $request = null ) : array
$prepared_args array Optional. Array of prepared arguments. Default empty array.
$request WP_REST_Request Optional. Request to prepare items for.
Результат array Array of query arguments.

update_item() публичный Метод

Updates a single attachment.
С версии: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, WP_Error object on failure.

upload_from_data() защищенный Метод

Handles an upload via raw POST data.
С версии: 4.7.0
protected upload_from_data ( array $data, array $headers ) : array | WP_Error
$data array Supplied file data.
$headers array HTTP headers from the request.
Результат array | WP_Error Data from wp_handle_sideload().

upload_from_file() защищенный Метод

Handles an upload via multipart/form-data ($_FILES).
С версии: 4.7.0
protected upload_from_file ( array $files, array $headers ) : array | WP_Error
$files array Data from the `$_FILES` superglobal.
$headers array HTTP headers from the request.
Результат array | WP_Error Data from wp_handle_upload().

validate_user_can_query_private_statuses() публичный Метод

Validates whether the user can query private statuses.
С версии: 4.7.0
public validate_user_can_query_private_statuses ( mixed $value, WP_REST_Request $request, string $parameter ) : WP_Error | boolean
$value mixed Status value.
$request WP_REST_Request Request object.
$parameter string Additional parameter to pass for validation.
Результат WP_Error | boolean True if the user may query, WP_Error if not.