WordPress.org

Make WordPress Core

Ticket #11276: 11276.2.diff

File 11276.2.diff, 2.7 KB (added by ryan, 8 years ago)

Untested

  • wp-includes/functions.php

     
    20352035        $siteurl = get_option( 'siteurl' );
    20362036        $upload_path = get_option( 'upload_path' );
    20372037        $upload_path = trim($upload_path);
    2038         if ( empty($upload_path) )
     2038        if ( empty($upload_path) ) {
    20392039                $dir = WP_CONTENT_DIR . '/uploads';
    2040         else
     2040        } else {
    20412041                $dir = $upload_path;
     2042                if ( 'wp-content/uploads' == $upload_path ) {
     2043                        $dir = WP_CONTENT_DIR . '/uploads';
     2044                } elseif ( 0 !== strpos($dir, ABSPATH) ) {
     2045                        // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
     2046                        $dir = path_join( ABSPATH, $dir );
     2047                }
     2048        }
    20422049
    2043         // $dir is absolute, $path is (maybe) relative to ABSPATH
    2044         $dir = path_join( ABSPATH, $dir );
    2045 
    20462050        if ( !$url = get_option( 'upload_url_path' ) ) {
    2047                 if ( empty($upload_path) or ( $upload_path == $dir ) )
     2051                if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
    20482052                        $url = WP_CONTENT_URL . '/uploads';
    20492053                else
    20502054                        $url = trailingslashit( $siteurl ) . $upload_path;
  • wp-admin/includes/schema.php

     
    190190        do_action('populate_options');
    191191
    192192        if ( ini_get('safe_mode') ) {
    193                 // Safe mode screws up mkdir(), so we must use a flat structure.
     193                // Safe mode can break mkdir() so use a flat structure by default.
    194194                $uploads_use_yearmonth_folders = 0;
    195                 $upload_path = WP_CONTENT_DIR;
    196195        } else {
    197196                $uploads_use_yearmonth_folders = 1;
    198                 $upload_path = WP_CONTENT_DIR . '/uploads';
    199197        }
    200198
    201199        $options = array(
     
    266264
    267265        // 2.0.1
    268266        'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
    269         'upload_path' => $upload_path,
     267        'upload_path' => '',
    270268
    271269        // 2.0.3
    272270        'secret' => wp_generate_password(64),
  • wp-admin/options-misc.php

     
    3030<table class="form-table">
    3131<tr valign="top">
    3232<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
    33 <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" />
     33<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
    3434<span class="description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></span>
    3535</td>
    3636</tr>