From b38c409b40611c7f73e2ff674aff3ca5e2dd4303 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 15 Dec 2009 17:53:51 +0000 Subject: [PATCH] Fix upload dir defaults. Props Denis-de-Bernardy. fixes #11276 git-svn-id: http://svn.automattic.com/wordpress/trunk@12405 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 6 ++---- wp-admin/options-misc.php | 2 +- wp-includes/functions.php | 16 ++++++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index cc2f08be62..bebbb0a818 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -189,12 +189,10 @@ function populate_options() { do_action('populate_options'); if ( ini_get('safe_mode') ) { - // Safe mode screws up mkdir(), so we must use a flat structure. + // Safe mode can break mkdir() so use a flat structure by default. $uploads_use_yearmonth_folders = 0; - $upload_path = WP_CONTENT_DIR; } else { $uploads_use_yearmonth_folders = 1; - $upload_path = WP_CONTENT_DIR . '/uploads'; } $options = array( @@ -265,7 +263,7 @@ function populate_options() { // 2.0.1 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, - 'upload_path' => $upload_path, + 'upload_path' => '', // 2.0.3 'secret' => wp_generate_password(64), diff --git a/wp-admin/options-misc.php b/wp-admin/options-misc.php index 9e22536706..73575a4e88 100644 --- a/wp-admin/options-misc.php +++ b/wp-admin/options-misc.php @@ -30,7 +30,7 @@ include('admin-header.php'); - diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 19ac29c949..5446f3e84f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2035,16 +2035,20 @@ function wp_upload_dir( $time = null ) { $siteurl = get_option( 'siteurl' ); $upload_path = get_option( 'upload_path' ); $upload_path = trim($upload_path); - if ( empty($upload_path) ) + if ( empty($upload_path) ) { $dir = WP_CONTENT_DIR . '/uploads'; - else + } else { $dir = $upload_path; - - // $dir is absolute, $path is (maybe) relative to ABSPATH - $dir = path_join( ABSPATH, $dir ); + if ( 'wp-content/uploads' == $upload_path ) { + $dir = WP_CONTENT_DIR . '/uploads'; + } elseif ( 0 !== strpos($dir, ABSPATH) ) { + // $dir is absolute, $upload_path is (maybe) relative to ABSPATH + $dir = path_join( ABSPATH, $dir ); + } + } if ( !$url = get_option( 'upload_url_path' ) ) { - if ( empty($upload_path) or ( $upload_path == $dir ) ) + if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) $url = WP_CONTENT_URL . '/uploads'; else $url = trailingslashit( $siteurl ) . $upload_path;
+ wp-content/uploads'); ?>