FileUpload final class
Minn\Runtime\FileUpload · public/minn/src/Minn/Runtime/FileUpload.php · 105 lines
A file a plugin hands to wp_handle_upload or wp_handle_sideload, taken in the reference's order (probe upload-filters, contracts/runtime.md "Uploads"): the action's prefilter, where a plugin sanitizes the file or refuses it with an error; its overrides; the upload's own errors, an empty file and, for a form upload, the form and the upload itself; the type, from the file's content as much as its name (wp_check_filetype_and_ext), refused unless the site allows it or the user may upload anything; the uploads folder; a unique, clean name (wp_unique_filename); pre_move_uploaded_file, where a plugin may move it itself; the move; and wp_handle_upload over the result.
Constants and properties
| private | UPLOAD_ERRORS = array ( 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 3 => 'The uploaded file was only partially uploaded.', 4 => 'No file was uploaded.', 6 => 'Missing a temporary folder.', 7 => 'Failed to write file to disk.', 8 => 'A PHP extension stopped the file upload.', ) |
Public
| static | handle(array $file, array|false $overrides, ?string $time, string $action): array# | The stored file (file, url, type) or ['error' => message].
@return array<string, mixed> |
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | refusal(array $file, array $options, string $action): ?string# | Why the upload stops before its type is looked at: a plugin's error from the prefilter, PHP's upload error, a form that is not the action's, an empty file, a form upload that did not arrive by POST.
| ||||||
| private | move(array $file, string $target, string $type, string $url, string $action): array# | pre_move_uploaded_file, then the move (a form upload's own move, a sideload's copy), the folder's permissions, and wp_handle_upload.
@return array<string, mixed> |
Nothing matches.