WordPress.org

Make WordPress Core

Ticket #9980: 9980.diff

File 9980.diff, 6.7 KB (added by dd32, 9 years ago)
  • wp-admin/includes/class-wp-filesystem-ftpext.php

     
    4747                        $this->wp_base = $opt['base'];
    4848
    4949                // Check if the options provided are OK.
    50                 if ( empty ($opt['username']) )
     50                if ( empty($opt['username']) )
    5151                        $this->errors->add('empty_username', __('FTP username is required'));
    5252                else
    5353                        $this->options['username'] = $opt['username'];
    5454
    55                 if ( empty ($opt['password']) )
     55                if ( empty($opt['password']) )
    5656                        $this->errors->add('empty_password', __('FTP password is required'));
    5757                else
    5858                        $this->options['password'] = $opt['password'];
    5959
    6060                $this->options['ssl'] = false;
    61                 if ( isset($opt['ssl']) )
    62                         $this->options['ssl'] = ( !empty($opt['ssl']) );
    63                 elseif ( isset( $opt['connection_type']) )
    64                         $this->options['ssl'] = ( 'ftps' == $opt['connection_type'] );
     61                if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
     62                        $this->options['ssl'] = true;
    6563        }
    6664
    6765        function connect() {
    6866                if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
    69                         $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'],$this->timeout);
     67                        $this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->timeout);
    7068                else
    71                         $this->link = @ftp_connect($this->options['hostname'], $this->options['port'],$this->timeout);
     69                        $this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->timeout);
    7270
    7371                if ( ! $this->link ) {
    7472                        $this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
  • wp-admin/includes/file.php

     
    593593        if ( ! $method )
    594594                return false;
    595595
    596         $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
    597         if( ! file_exists($abstraction_file) )
    598                 return;
    599 
    600         require_once($abstraction_file);
     596        if ( ! class_exists("WP_Filesystem_$method") ) {
     597                $abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
     598                if( ! file_exists($abstraction_file) )
     599                        return;
     600       
     601                require_once($abstraction_file);
     602        }
    601603        $method = "WP_Filesystem_$method";
    602604
    603605        $wp_filesystem = new $method($args);
     
    685687        else
    686688                unset($credentials['port']);
    687689
    688         if ( defined('FTP_SSH') || (isset($_POST['connection_type']) && 'ssh' == $_POST['connection_type']) )
     690        if ( defined('FTP_SSH') || (defined('FS_METHOD') && 'ssh' == FS_METHOD) )
    689691                $credentials['connection_type'] = 'ssh';
    690         else if ( defined('FTP_SSL') || (isset($_POST['connection_type']) && 'ftps' == $_POST['connection_type']) )
     692        else if ( defined('FTP_SSL') && 'ftpext' == $type ) //Only the FTP Extension understands SSL
    691693                $credentials['connection_type'] = 'ftps';
    692         else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) )
     694        else if ( !empty($_POST['connection_type']) )
     695                $credentials['connection_type'] = $_POST['connection_type'];
     696        else if ( !isset($credentials['connection_type']) ) //All else fails (And its not defaulted to something else saved), Default to FTP
    693697                $credentials['connection_type'] = 'ftp';
    694698
    695699        if ( ! $error &&
     
    750754
    751755<tr valign="top">
    752756<th scope="row"><label for="password"><?php _e('Password') ?></label></th>
    753 <td><input name="password" type="password" id="password" value=""<?php if( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /><?php if( defined('FTP_PASS') && !empty($password) ) echo '<em>'.__('(Password not shown)').'</em>'; ?></td>
     757<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php if ( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /></td>
    754758</tr>
    755759
     760<?php if ( extension_loaded('ssh2') ) : ?>
    756761<tr id="ssh_keys" valign="top" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>">
    757762<th scope="row"><?php _e('Authentication Keys') ?>
    758763<div class="key-labels textright">
     
    762767<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
    763768<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
    764769</tr>
     770<?php endif; ?>
    765771
    766772<tr valign="top">
    767773<th scope="row"><?php _e('Connection Type') ?></th>
    768774<td>
    769775<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend>
    770 <label><input id="ftp" name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTP') ?></label><br />
    771 <label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); if ( defined('FTP_SSH') || defined('FTP_SSH') ) echo ' disabled="disabled"';  ?>/> <?php _e('FTPS (SSL)') ?></label><br />
    772 <?php if ( extension_loaded('ssh2') ) { ?><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type);  if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('SSH') ?></label><?php } ?>
     776<label><input id="ftp" name="connection_type"  type="radio" value="ftp" <?php checked('ftp', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('FTP') ?></label>
     777<?php if ( 'ftpext' == $type ) : ?>
     778<br /><label><input id="ftps" name="connection_type" type="radio" value="ftps" <?php checked('ftps', $connection_type); if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"';  ?>/> <?php _e('FTPS (SSL)') ?></label>
     779<?php endif; ?>
     780<?php if ( extension_loaded('ssh2') ) : ?>
     781<br /><label><input id="ssh" name="connection_type" type="radio" value="ssh" <?php checked('ssh', $connection_type);  if ( defined('FTP_SSL') || defined('FTP_SSH') ) echo ' disabled="disabled"'; ?>/> <?php _e('SSH') ?></label>
     782<?php endif; ?>
    773783</fieldset>
    774784</td>
    775785</tr>