[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

REST API: WP_REST_Attachments_Controller class

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

Defines 1 class

WP_REST_Attachments_Controller:: (20 methods):
  register_routes()
  prepare_items_query()
  create_item_permissions_check()
  create_item()
  insert_attachment()
  update_item()
  post_process_item()
  post_process_item_permissions_check()
  edit_media_item_permissions_check()
  edit_media_item()
  prepare_item_for_database()
  prepare_item_for_response()
  get_item_schema()
  upload_from_data()
  get_filename_from_disposition()
  get_collection_params()
  upload_from_file()
  get_media_types()
  check_upload_size()
  get_edit_media_item_args()


Class: WP_REST_Attachments_Controller  - X-Ref

Core controller used to access attachments via the REST API.

register_routes()   X-Ref
Registers the routes for attachments.

since: 5.3.0

prepare_items_query( $prepared_args = array()   X-Ref
Determines the allowed query_vars for a get_items() response and
prepares for WP_Query.

param: array           $prepared_args Optional. Array of prepared arguments. Default empty array.
param: WP_REST_Request $request       Optional. Request to prepare items for.
return: array Array of query arguments.
since: 4.7.0

create_item_permissions_check( $request )   X-Ref
Checks if a given request has access to create an attachment.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error Boolean true if the attachment may be created, or a WP_Error if not.
since: 4.7.0

create_item( $request )   X-Ref
Creates a single attachment.

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

insert_attachment( $request )   X-Ref
Inserts the attachment post in the database. Does not update the attachment meta.

param: WP_REST_Request $request
return: array|WP_Error
since: 5.3.0

update_item( $request )   X-Ref
Updates a single attachment.

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

post_process_item( $request )   X-Ref
Performs post processing on an attachment.

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

post_process_item_permissions_check( $request )   X-Ref
Checks if a given request can perform post processing on an attachment.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True if the request has access to update the item, WP_Error object otherwise.
since: 5.3.0

edit_media_item_permissions_check( $request )   X-Ref
Checks if a given request has access to editing media.

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

edit_media_item( $request )   X-Ref
Applies edits to a media item and creates a new attachment record.

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

prepare_item_for_database( $request )   X-Ref
Prepares a single attachment for create or update.

param: WP_REST_Request $request Request object.
return: stdClass|WP_Error Post object.
since: 4.7.0

prepare_item_for_response( $item, $request )   X-Ref
Prepares a single attachment output for response.

param: WP_Post         $item    Attachment object.
param: WP_REST_Request $request Request object.
return: WP_REST_Response Response object.
since: 4.7.0
since: 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.

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

return: array Item schema as an array.
since: 4.7.0

upload_from_data( $data, $headers )   X-Ref
Handles an upload via raw POST data.

param: array $data    Supplied file data.
param: array $headers HTTP headers from the request.
return: array|WP_Error Data from wp_handle_sideload().
since: 4.7.0

get_filename_from_disposition( $disposition_header )   X-Ref
Parses filename from a Content-Disposition header value.

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           = <the characters in token, followed by "*">

param: string[] $disposition_header List of Content-Disposition header values.
return: string|null Filename if available, or null if not found.
since: 4.7.0

get_collection_params()   X-Ref
Retrieves the query params for collections of attachments.

return: array Query parameters for the attachment collection as an array.
since: 4.7.0

upload_from_file( $files, $headers )   X-Ref
Handles an upload via multipart/form-data ($_FILES).

param: array $files   Data from the `$_FILES` superglobal.
param: array $headers HTTP headers from the request.
return: array|WP_Error Data from wp_handle_upload().
since: 4.7.0

get_media_types()   X-Ref
Retrieves the supported media types.

Media types are considered the MIME type category.

return: array Array of supported media types.
since: 4.7.0

check_upload_size( $file )   X-Ref
Determine if uploaded file exceeds space quota on multisite.

Replicates check_upload_size().

param: array $file $_FILES array for a given file.
return: true|WP_Error True if can upload, error for errors.
since: 4.9.8

get_edit_media_item_args()   X-Ref
Gets the request args for the edit item route.

return: array
since: 5.5.0



Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1