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
This commit is contained in:
ryan 2009-12-15 17:53:51 +00:00
parent 57a16afcb2
commit b38c409b40
3 changed files with 13 additions and 11 deletions

View File

@ -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),

View File

@ -30,7 +30,7 @@ include('admin-header.php');
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(str_replace(ABSPATH, '', get_option('upload_path'))); ?>" class="regular-text code" />
<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
<span class="description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></span>
</td>
</tr>

View File

@ -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;