diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index c999d5d781..92d8bc2ac4 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -72,7 +72,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { else $this->options['password'] = $opt['password']; - $this->options['ssl'] = ( !empty($opt['ssl']) ); + $this->options['ssl'] = false; + if ( isset($opt['ssl']) ) + $this->options['ssl'] = ( !empty($opt['ssl']) ); + elseif ( isset( $opt['connection_type']) ) + $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] ); } function connect() { diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index b5a614fef6..c57e3d0f2c 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -448,7 +448,7 @@ function WP_Filesystem( $args = false ) { require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); - $method = get_filesystem_method(); + $method = get_filesystem_method($args); if ( ! $method ) return false; @@ -471,7 +471,7 @@ function WP_Filesystem( $args = false ) { return true; } -function get_filesystem_method() { +function get_filesystem_method($args = array()) { $method = false; if( function_exists('getmyuid') && function_exists('fileowner') ){ $temp_file = wp_tempnam(); @@ -480,6 +480,11 @@ function get_filesystem_method() { unlink($temp_file); } + if ( isset($args['connection_type']) && 'ssh' == $args['connection_type'] ) { + $method = 'SSH2'; + return apply_filters('filesystem_method', $method); + } + if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread return apply_filters('filesystem_method', $method); @@ -502,7 +507,12 @@ function request_filesystem_credentials($form_post, $type = '', $error = false) $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']); $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']); $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']); - $credentials['ssl'] = defined('FTP_SSL') ? FTP_SSL : ( isset($_POST['ssl']) ? $_POST['ssl'] : $credentials['ssl']); + if ( defined('FTP_SSH') || 'ssh' == $_POST['connection_type'] ) + $credentials['connection_type'] = 'ssh'; + else if ( defined('FTP_SSL') || 'ftps' == $_POST['connection_type'] ) + $credentials['connection_type'] = 'ftps'; + else + $credentials['connection_type'] = 'ftp'; if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { $stored_credentials = $credentials; @@ -516,8 +526,12 @@ function request_filesystem_credentials($form_post, $type = '', $error = false) $ssl = ''; if ( !empty($credentials) ) extract($credentials, EXTR_OVERWRITE); - if( $error ) - echo '
' . __('Error: There was an error connecting to the server, Please verify the settings are correct.') . '
' . $error_string . '