From 43a1c703e062b2c41bbd3bbe40a29e70dd26eca1 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 23 Oct 2012 13:49:00 +0000 Subject: [PATCH] A more generic message for wp_upload_dir(). Props nacin. fixes #21796 git-svn-id: http://core.svn.wordpress.org/trunk@22276 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c7d390bd40..ade297aa66 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1570,7 +1570,12 @@ function wp_upload_dir( $time = null ) { // 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'] ); + if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) + $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; + else + $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; + + $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); $uploads['error'] = $message; } @@ -1688,7 +1693,12 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { $new_file = $upload['path'] . "/$filename"; if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { - $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), dirname( $new_file ) ); + if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) + $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; + else + $error_path = basename( $upload['basedir'] ) . $upload['subdir']; + + $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); return array( 'error' => $message ); }