WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 339 | * @param array $upload { |
| 340 | * Array of upload data. |
| 341 | * |
| 342 | * @type string $file Filename of the newly-uploaded file. |
| 343 | * @type string $url URL of the uploaded file. |
| 344 | * @type string $type File type. |
| 345 | * } |
| 346 | * @param string $context The type of upload action. Accepts 'upload' or 'sideload'. |
| 347 | */ |
| 348 | return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' ); |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Handle sideloads, which is the process of retrieving a media item from another server instead of |
| 353 | * a traditional media upload. This process involves sanitizing the filename, checking extensions |
| 354 | * for mime type, and moving the file to the appropriate directory within the uploads directory. |
| 355 | * |
| 356 | * @since 2.6.0 |
| 357 | * |
| Line | Code |
| 464 | // Set correct file permissions |
| 465 | $stat = stat( dirname( $new_file )); |
| 466 | $perms = $stat['mode'] & 0000666; |
| 467 | @ chmod( $new_file, $perms ); |
| 468 | |
| 469 | // Compute the URL |
| 470 | $url = $uploads['url'] . "/$filename"; |
| 471 | |
| 472 | /** This filter is documented in wp-admin/includes/file.php */ |
| 473 | $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'sideload' ); |
| 474 | |
| 475 | return $return; |
| 476 | } |
| 477 | |
| 478 | /** |
| 479 | * Downloads a url to a local temporary file using the WordPress HTTP Class. |
| 480 | * Please note, That the calling function must unlink() the file. |
| 481 | * |
| 482 | * @since 2.5.0 |