Allow uploads outside of the WP path and custom URLs for the same.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6780 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt
2008-02-11 06:35:24 +00:00
parent 9aab2ce97a
commit d9738d6cfb
3 changed files with 19 additions and 5 deletions

View File

@@ -1026,10 +1026,16 @@ function wp_mkdir_p( $target ) {
// Returns an array containing the current upload directory's path and url, or an error message.
function wp_upload_dir( $time = NULL ) {
$siteurl = get_option( 'siteurl' );
//prepend ABSPATH to $dir and $siteurl to $url if they're not already there
$path = str_replace( ABSPATH, '', trim( get_option( 'upload_path' ) ) );
$dir = ABSPATH . $path;
$url = trailingslashit( $siteurl ) . $path;
$upload_path = $dir = get_option( 'upload_path' );
if ( $upload_path != realpath( $upload_path ) ) { // not an absolute path
//prepend ABSPATH to $dir and $siteurl to $url if they're not already there
$path = str_replace( ABSPATH, '', trim( $upload_path ) );
$dir = ABSPATH . $path;
}
if ( !$url = get_option( 'upload_url_path' ) )
$url = trailingslashit( $siteurl ) . $path;
if ( $dir == ABSPATH ) // the option was empty
$dir = ABSPATH . 'wp-content/uploads';