Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_handle_upload

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
353      $perms = $stat['mode'] & 0000666;
354      @ chmod( $new_file, $perms );
355
356      // Compute the URL
357      $url = $uploads['url'] . "/$filename";
358
359      if ( is_multisite() )
360           delete_transient( 'dirsize_cache' );
361
362      return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' );
363 }
364
365 /**
366  * Handle sideloads, which is the process of retrieving a media item from another server instead of
367  * a traditional media upload.  This process involves sanitizing the filename, checking extensions
368  * for mime type, and moving the file to the appropriate directory within the uploads directory.
369  *
370  * @since 2.6.0
371  *
 
Line Code
473
474      // Set correct file permissions
475      $stat = stat( dirname( $new_file ));
476      $perms = $stat['mode'] & 0000666;
477      @ chmod( $new_file, $perms );
478
479      // Compute the URL
480      $url = $uploads['url'] . "/$filename";
481
482      $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'sideload' );
483
484      return $return;
485 }
486
487 /**
488  * Downloads a url to a local temporary file using the WordPress HTTP Class.
489  * Please note, That the calling function must unlink() the  file.
490  *
491  * @since 2.5.0