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
202
203      // Set correct file permissions
204      $stat = stat( dirname( $new_file ));
205      $perms = $stat['mode'] & 0000666;
206      @ chmod( $new_file, $perms );
207
208      // Compute the URL
209      $url = $uploads['url'] . "/$filename";
210
211      $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
212
213      return $return;
214 }
215 // Pass this function an array similar to that of a $_FILES POST array.
216 function wp_handle_sideload( &$file, $overrides = false ) {
217      // The default error handler.
218      if (! function_exists( 'wp_handle_upload_error' ) ) {
219           function wp_handle_upload_error( &$file, $message ) {
220                return array( 'error'=>$message );
 
Line Code
298
299      // Set correct file permissions
300      $stat = stat( dirname( $new_file ));
301      $perms = $stat['mode'] & 0000666;
302      @ chmod( $new_file, $perms );
303
304      // Compute the URL
305      $url = $uploads['url'] . "/$filename";
306
307      $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) );
308
309      return $return;
310 }
311
312 /**
313 * Downloads a url to a local file using the Snoopy HTTP Class
314 *
315 * @param string $url the URL of the file to download
316 * @return mixed WP_Error on failure, string Filename on success.