diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 24cfd2cb8b..666bfdbfc5 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -523,36 +523,6 @@ function saveDomDocument($doc, $filename) { fclose($fp); } -/** - * Workaround for Windows bug in is_writable() function - * - * @since 2.8.0 - * - * @param string $path - * @return bool - */ -function win_is_writable( $path ) { - /* will work in despite of Windows ACLs bug - * NOTE: use a trailing slash for folders!!! - * see http://bugs.php.net/bug.php?id=27609 - * see http://bugs.php.net/bug.php?id=30931 - */ - - if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path - return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); - else if ( is_dir( $path ) ) - return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); - // check tmp file for read/write capabilities - $should_delete_tmp_file = !file_exists( $path ); - $f = @fopen( $path, 'a' ); - if ( $f === false ) - return false; - fclose( $f ); - if ( $should_delete_tmp_file ) - unlink( $path ); - return true; -} - /** * Display the default admin color scheme picker (Used in user-edit.php) * diff --git a/wp-includes/functions.php b/wp-includes/functions.php index f541c787b4..e51c155ed1 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1408,6 +1408,36 @@ function get_temp_dir() { return $temp; } +/** + * Workaround for Windows bug in is_writable() function + * + * @since 2.8.0 + * + * @param string $path + * @return bool + */ +function win_is_writable( $path ) { + /* will work in despite of Windows ACLs bug + * NOTE: use a trailing slash for folders!!! + * see http://bugs.php.net/bug.php?id=27609 + * see http://bugs.php.net/bug.php?id=30931 + */ + + if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path + return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); + else if ( is_dir( $path ) ) + return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); + // check tmp file for read/write capabilities + $should_delete_tmp_file = !file_exists( $path ); + $f = @fopen( $path, 'a' ); + if ( $f === false ) + return false; + fclose( $f ); + if ( $should_delete_tmp_file ) + unlink( $path ); + return true; +} + /** * Get an array containing the current upload directory's path and url. *