Make WordPress Core


Ignore:
Timestamp:
01/09/2006 10:24:57 PM (21 years ago)
Author:
ryan
Message:

Add upload folder options. Props David House. fixes #2206

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-post.php

    r3403 r3413  
    877877// Returns an array containing the current upload directory's path and url, or an error message.
    878878function wp_upload_dir() {
    879         $dir = trim(get_settings('fileupload_realpath'));
    880         $url = trim(get_settings('fileupload_url'));
    881 
    882         $custom = true;
    883         if ( empty($dir) || empty($url) ) {
     879        $siteurl = get_settings('siteurl');
     880        //prepend ABSPATH to $dir and $siteurl to $url if they're not already there
     881        $dir = ABSPATH . str_replace(ABSPATH, '', trim(get_settings('fileupload_realpath')));
     882        $url = $siteurl . str_replace($siteurl, '', trim(get_settings('fileupload_url')));
     883
     884        if ( $dir == ABSPATH ) { //the option was empty
    884885                $dir = ABSPATH . 'wp-content/uploads';
    885                 $url = get_option('siteurl') . '/wp-content/uploads';
    886                 $custom = false;
     886        }
     887        if ( $url == $siteurl ) { //the option was empty
     888                $url = get_option('siteurl') . '/' . str_replace(ABSPATH, '', $dir);
    887889        }
    888890
     
    890892                $dir = ABSPATH . UPLOADS;
    891893                $url =  get_option('siteurl') . '/' . UPLOADS;
    892                 $custom = false;
    893         }
    894 
    895         if ( ! $custom) {
     894        }
     895
     896        if ( get_settings('uploads_yearmonth_folders')) {
    896897                // Generate the yearly and monthly dirs
    897898                $time = current_time( 'mysql' );
Note: See TracChangeset for help on using the changeset viewer.