Make WordPress Core

Changeset 49845

Timestamp:
12/20/2020 04:13:23 PM (4 years ago)
Author:
johnbillion
Message:

Upload: Introduce the {$action}_overrides filter that allows the overrides parameter for file uploads and file sideloads to be filtered.

The dynamic portion of the hook name, $action, refers to the post action.

Props iandunn, jakub.tyrcha, nacin, wonderboymusic, Mte90, johnbillion

Fixes #16849

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r49616 r49845  
    726726 * @param string[]       $file      Reference to a single element of `$_FILES`.
    727727 *                                  Call the function once for each uploaded file.
    728  * @param string[]|false $overrides An associative array of names => values
    729  *                                  to override default variables. Default false.
     728 * @param array|false    $overrides {
     729 *     An array of override parameters for this file, or boolean false if none are provided.
     730 *
     731 *     @type callable $upload_error_handler     Function to call when there is an error during the upload process.
     732 *                                              @see wp_handle_upload_error().
     733 *     @type callable $unique_filename_callback Function to call when determining a unique file name for the file.
     734 *                                              @see wp_unique_filename().
     735 *     @type string[] $upload_error_strings     The strings that describe the error indicated in
     736 *                                              `$_FILES[{form field}]['error']`.
     737 *     @type bool     $test_form                Whether to test that the `$_POST['action]` parameter is as expected.
     738 *     @type bool     $test_size                Whether to test that the file size is greater than zero bytes.
     739 *     @type bool     $test_type                Whether to test that the mime type of the file is as expected.
     740 *     @type string[] $mimes                    Array of allowed mime types keyed by their file extension regex.
     741 * }
    730742 * @param string         $time      Time formatted in 'yyyy/mm'.
    731743 * @param string         $action    Expected value for `$_POST['action']`.
     
    746758     *
    747759     * The dynamic portion of the hook name, `$action`, refers to the post action.
     760
     761
     762
     763
    748764     *
    749765     * @since 2.9.0 as 'wp_handle_upload_prefilter'.
    750766     * @since 4.0.0 Converted to a dynamic hook with `$action`.
    751767     *
    752      * @param string[] $file An array of data for a single file.
     768     * @param string[] $file An array of data for .
    753769     */
    754770    $file = apply_filters( "{$action}_prefilter", $file );
     771
     772
     773
     774
     775
     776
     777
     778
     779
     780
     781
     782
     783
     784
     785
     786
     787
    755788
    756789    // You may define your own function and pass the name in $overrides['upload_error_handler'].
  • trunk/src/wp-admin/includes/media.php

    r49384 r49845  
    431431 * @since 5.3.0 The `$post_id` parameter was made optional.
    432432 *
    433  * @param array  $file_array Array similar to a `$_FILES` upload array.
     433 * @param array  $file_array Array a `$_FILES` upload array.
    434434 * @param int    $post_id    Optional. The post ID the media is associated with.
    435435 * @param string $desc       Optional. Description of the side-loaded file. Default null.
  • trunk/src/wp-includes/functions.php

    r49790 r49845  
    27922792 *
    27932793 * @param string   $filename File name or path.
    2794  * @param string[] $mimes    Optional. Array of mime types keyed by their file extension regex.
     2794 * @param string[] $mimes    Optional. Array of mime types keyed by their file extension regex.
    27952795 * @return array {
    27962796 *     Values for the extension and mime type.
     
    28342834 * @param string   $filename The name of the file (may differ from $file due to $file being
    28352835 *                           in a tmp directory).
    2836  * @param string[] $mimes    Optional. Array of mime types keyed by their file extension regex.
     2836 * @param string[] $mimes    Optional. Array of mime types keyed by their file extension regex.
    28372837 * @return array {
    28382838 *     Values for the extension, mime type, and corrected filename.
Note: See TracChangeset for help on using the changeset viewer.