diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 3f4329aff6..8f07d4f0dc 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1467,8 +1467,8 @@ function wp_upload_dir( $time = null ) { $url = str_replace( UPLOADS, 'files', $url ); } - $bdir = $dir; - $burl = $url; + $basedir = $dir; + $baseurl = $url; $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { @@ -1483,12 +1483,20 @@ function wp_upload_dir( $time = null ) { $dir .= $subdir; $url .= $subdir; - $uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) ); + $uploads = apply_filters( 'upload_dir', + array( + 'path' => $dir, + 'url' => $url, + 'subdir' => $subdir, + 'basedir' => $basedir, + 'baseurl' => $baseurl, + 'error' => false, + ) ); // Make sure we have an uploads dir if ( ! wp_mkdir_p( $uploads['path'] ) ) { $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] ); - return array( 'error' => $message ); + $uploads['error'] = $message; } return $uploads; diff --git a/wp-includes/post.php b/wp-includes/post.php index 0ad295c5f5..88df9fa7e9 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -223,11 +223,10 @@ function update_attached_file( $attachment_id, $file ) { function _wp_relative_upload_path( $path ) { $new_path = $path; - if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { - if ( 0 === strpos($new_path, $uploads['basedir']) ) { - $new_path = str_replace($uploads['basedir'], '', $new_path); - $new_path = ltrim($new_path, '/'); - } + $uploads = wp_upload_dir(); + if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) { + $new_path = str_replace( $uploads['basedir'], '', $new_path ); + $new_path = ltrim( $new_path, '/' ); } return apply_filters( '_wp_relative_upload_path', $new_path, $path );