From bfa3b629e0d67016ec83050c5db762479af40609 Mon Sep 17 00:00:00 2001 From: donncha Date: Wed, 13 Aug 2008 15:13:05 +0000 Subject: Merge with WP revision 8635 git-svn-id: http://svn.automattic.com/wordpress-mu/branches/2.6@1421 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/functions.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'wp-includes/functions.php') diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 332f831..261097e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -620,12 +620,12 @@ function delete_option( $name ) { * @return mixed A scalar data */ function maybe_serialize( $data ) { - if ( is_string( $data ) ) - return $data; - elseif ( is_array( $data ) || is_object( $data ) ) + if ( is_array( $data ) || is_object( $data ) ) return serialize( $data ); + if ( is_serialized( $data ) ) return serialize( $data ); + return $data; } @@ -1473,15 +1473,21 @@ function path_join( $base, $path ) { function wp_upload_dir( $time = NULL ) { $siteurl = get_option( 'siteurl' ); $upload_path = get_option( 'upload_path' ); - if ( trim($upload_path) === '' ) - $upload_path = WP_CONTENT_DIR . '/uploads'; - $dir = $upload_path; + $upload_path = trim($upload_path); + if ( empty($upload_path) ) + $dir = WP_CONTENT_DIR . '/uploads'; + else + $dir = $upload_path; // $dir is absolute, $path is (maybe) relative to ABSPATH - $dir = path_join( ABSPATH, $upload_path ); - - if ( !$url = get_option( 'upload_url_path' ) ) - $url = WP_CONTENT_URL . '/uploads'; + $dir = path_join( ABSPATH, $dir ); + + if ( !$url = get_option( 'upload_url_path' ) ) { + if ( empty($upload_path) or ( $upload_path == $dir ) ) + $url = WP_CONTENT_URL . '/uploads'; + else + $url = trailingslashit( $siteurl ) . $upload_path; + } if ( defined('UPLOADS') ) { $dir = ABSPATH . UPLOADS; @@ -1509,8 +1515,9 @@ function wp_upload_dir( $time = NULL ) { $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $dir ); return array( 'error' => $message ); } - + $uploads = array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ); + return apply_filters( 'upload_dir', $uploads ); } -- cgit