Add upload folder options. Props David House. fixes #2206
git-svn-id: http://svn.automattic.com/wordpress/trunk@3413 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -876,23 +876,24 @@ function wp_mkdir_p($target) {
|
||||
|
||||
// Returns an array containing the current upload directory's path and url, or an error message.
|
||||
function wp_upload_dir() {
|
||||
$dir = trim(get_settings('fileupload_realpath'));
|
||||
$url = trim(get_settings('fileupload_url'));
|
||||
$siteurl = get_settings('siteurl');
|
||||
//prepend ABSPATH to $dir and $siteurl to $url if they're not already there
|
||||
$dir = ABSPATH . str_replace(ABSPATH, '', trim(get_settings('fileupload_realpath')));
|
||||
$url = $siteurl . str_replace($siteurl, '', trim(get_settings('fileupload_url')));
|
||||
|
||||
$custom = true;
|
||||
if ( empty($dir) || empty($url) ) {
|
||||
if ( $dir == ABSPATH ) { //the option was empty
|
||||
$dir = ABSPATH . 'wp-content/uploads';
|
||||
$url = get_option('siteurl') . '/wp-content/uploads';
|
||||
$custom = false;
|
||||
}
|
||||
if ( $url == $siteurl ) { //the option was empty
|
||||
$url = get_option('siteurl') . '/' . str_replace(ABSPATH, '', $dir);
|
||||
}
|
||||
|
||||
if ( defined('UPLOADS') ) {
|
||||
$dir = ABSPATH . UPLOADS;
|
||||
$url = get_option('siteurl') . '/' . UPLOADS;
|
||||
$custom = false;
|
||||
}
|
||||
|
||||
if ( ! $custom) {
|
||||
if ( get_settings('uploads_yearmonth_folders')) {
|
||||
// Generate the yearly and monthly dirs
|
||||
$time = current_time( 'mysql' );
|
||||
$y = substr( $time, 0, 4 );
|
||||
|
||||
@@ -355,12 +355,13 @@ function update_option($option_name, $newvalue) {
|
||||
|
||||
// If the new and old values are the same, no need to update.
|
||||
$oldvalue = get_option($option_name);
|
||||
if ( $newvalue == $oldvalue )
|
||||
if ( $newvalue == $oldvalue ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( false === $oldvalue ) {
|
||||
add_option($option_name, $newvalue);
|
||||
return true;
|
||||
if ( false === $oldvalue ) {
|
||||
add_option($option_name, $newvalue);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_array($newvalue) || is_object($newvalue) )
|
||||
|
||||
Reference in New Issue
Block a user