Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: upload_dir

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

Line Code
1109      $url .= $subdir;
1110
1111      // Make sure we have an uploads dir
1112      if ( ! wp_mkdir_p( $dir ) ) {
1113           $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir );
1114           return array( 'error' => $message );
1115      }
1116
1117      $uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'error' => false );
1118      return apply_filters( 'upload_dir', $uploads );
1119 }
1120
1121 // return a filename that is sanitized and unique for the given directory
1122 function wp_unique_filename( $dir, $filename, $unique_filename_callback = NULL ) {
1123      $filename = strtolower( $filename );
1124      // separate the filename into a name and extension
1125      $info = pathinfo($filename);
1126      $ext = $info['extension'];
1127      $name = basename($filename, ".{$ext}");