PHP Class WP_REST_Attachments_Controller, wordpress

Inheritance: extends WP_REST_Posts_Controller
Afficher le fichier Open project: johnpbloch/wordpress Class Usage Examples

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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).

Method Details

create_item() public méthode

Creates a single attachment.
Since: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Résultat WP_Error | WP_REST_Response Response object on success, WP_Error object on failure.

create_item_permissions_check() public méthode

Checks if a given request has access to create an attachment.
Since: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : WP_Error | true
$request WP_REST_Request Full details about the request.
Résultat WP_Error | true Boolean true if the attachment may be created, or a WP_Error if not.

get_collection_params() public méthode

Retrieves the query params for collections of attachments.
Since: 4.7.0
public get_collection_params ( ) : array
Résultat array Query parameters for the attachment collection as an array.

get_filename_from_disposition() public static méthode

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 =
public static get_filename_from_disposition ( string[] $disposition_header ) : string | null
$disposition_header string[] List of Content-Disposition header values.
Résultat string | null Filename if available, or null if not found.

get_item_schema() public méthode

Retrieves the attachment's schema, conforming to JSON Schema.
Since: 4.7.0
public get_item_schema ( ) : array
Résultat array Item schema as an array.

get_media_types() protected méthode

Media types are considered the MIME type category.
Since: 4.7.0
protected get_media_types ( ) : array
Résultat array Array of supported media types.

prepare_item_for_database() protected méthode

Prepares a single attachment for create or update.
Since: 4.7.0
protected prepare_item_for_database ( WP_REST_Request $request ) : WP_Error | stdClass
$request WP_REST_Request Request object.
Résultat WP_Error | stdClass $prepared_attachment Post object.

prepare_item_for_response() public méthode

Prepares a single attachment output for response.
Since: 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.
Résultat WP_REST_Response Response object.

prepare_items_query() protected méthode

Determines the allowed query_vars for a get_items() response and prepares for WP_Query.
Since: 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.
Résultat array Array of query arguments.

update_item() public méthode

Updates a single attachment.
Since: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Résultat WP_Error | WP_REST_Response Response object on success, WP_Error object on failure.

upload_from_data() protected méthode

Handles an upload via raw POST data.
Since: 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.
Résultat array | WP_Error Data from wp_handle_sideload().

upload_from_file() protected méthode

Handles an upload via multipart/form-data ($_FILES).
Since: 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.
Résultat array | WP_Error Data from wp_handle_upload().

validate_user_can_query_private_statuses() public méthode

Validates whether the user can query private statuses.
Since: 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.
Résultat WP_Error | boolean True if the user may query, WP_Error if not.