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'); do_action('populate_options');
if ( ini_get('safe_mode') ) { 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; $uploads_use_yearmonth_folders = 0;
$upload_path = WP_CONTENT_DIR;
} else { } else {
$uploads_use_yearmonth_folders = 1; $uploads_use_yearmonth_folders = 1;
$upload_path = WP_CONTENT_DIR . '/uploads';
} }
$options = array( $options = array(
@ -265,7 +263,7 @@ function populate_options() {
// 2.0.1 // 2.0.1
'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, 'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
'upload_path' => $upload_path, 'upload_path' => '',
// 2.0.3 // 2.0.3
'secret' => wp_generate_password(64), 'secret' => wp_generate_password(64),

View File

@ -30,7 +30,7 @@ include('admin-header.php');
<table class="form-table"> <table class="form-table">
<tr valign="top"> <tr valign="top">
<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th> <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> <span class="description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></span>
</td> </td>
</tr> </tr>

View File

@ -2035,16 +2035,20 @@ function wp_upload_dir( $time = null ) {
$siteurl = get_option( 'siteurl' ); $siteurl = get_option( 'siteurl' );
$upload_path = get_option( 'upload_path' ); $upload_path = get_option( 'upload_path' );
$upload_path = trim($upload_path); $upload_path = trim($upload_path);
if ( empty($upload_path) ) if ( empty($upload_path) ) {
$dir = WP_CONTENT_DIR . '/uploads'; $dir = WP_CONTENT_DIR . '/uploads';
else } else {
$dir = $upload_path; $dir = $upload_path;
if ( 'wp-content/uploads' == $upload_path ) {
// $dir is absolute, $path is (maybe) relative to ABSPATH $dir = WP_CONTENT_DIR . '/uploads';
$dir = path_join( ABSPATH, $dir ); } 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 ( !$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'; $url = WP_CONTENT_URL . '/uploads';
else else
$url = trailingslashit( $siteurl ) . $upload_path; $url = trailingslashit( $siteurl ) . $upload_path;