Make WordPress Core

Changeset 7297


Ignore:
Timestamp:
03/14/2008 07:11:41 PM (16 years ago)
Author:
ryan
Message:

Allow hardcoding of FTP connection info. Props DD32. see #5586

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/update.php

    r7238 r7297  
    1212    if ( 'direct' == $type )
    1313        return array();
     14       
     15    if( ! $credentials = get_option('ftp_credentials') )
     16        $credentials = array();
     17    // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
     18    $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? $_POST['hostname'] : $credentials['hostname']);
     19    $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? $_POST['username'] : $credentials['username']);
     20    $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? $_POST['password'] : $credentials['password']);
     21    $credentials['ssl']      = defined('FTP_SSL')  ? FTP_SSL  : (!empty($_POST['ssl'])      ? $_POST['ssl']      : $credentials['ssl']);
    1422
    15     if ( ! $error && !empty($_POST['password']) && !empty($_POST['username']) && !empty($_POST['hostname']) ) {
    16         $credentials = array('hostname' => $_POST['hostname'], 'username' => $_POST['username'],
    17             'password' => $_POST['password'], 'ssl' => $_POST['ssl']);
     23    if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) {
    1824        $stored_credentials = $credentials;
    1925        unset($stored_credentials['password']);
     
    2531    $password = '';
    2632    $ssl = '';
    27     if ( $credentials = get_option('ftp_credentials') )
     33    if ( !empty($credentials) )
    2834        extract($credentials, EXTR_OVERWRITE);
    29     if( $error ){
     35    if( $error )
    3036        echo '<div id="message" class="error"><p>' . __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.') . '</p></div>';
    31     }
    3237?>
    3338<form action="<?php echo $form_post ?>" method="post">
     
    3843<tr valign="top">
    3944<th scope="row"><?php _e('Hostname:') ?></th>
    40 <td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>" size="40" /></td>
     45<td><input name="hostname" type="text" id="hostname" value="<?php echo attribute_escape($hostname) ?>"<?php if( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
    4146</tr>
    4247<tr valign="top">
    4348<th scope="row"><?php _e('Username:') ?></th>
    44 <td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>" size="40" /></td>
     49<td><input name="username" type="text" id="username" value="<?php echo attribute_escape($username) ?>"<?php if( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
    4550</tr>
    4651<tr valign="top">
    4752<th scope="row"><?php _e('Password:') ?></th>
    48 <td><input name="password" type="password" id="password" value="<?php echo attribute_escape($password) ?>" size="40" /></td>
     53<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) ) _e('<em>(Password not shown)</em>'); ?></td>
    4954</tr>
    5055<tr valign="top">
    5156<th scope="row"><?php _e('Use SSL:') ?></th>
    5257<td>
    53 <select name="ssl" id="ssl">
     58<select name="ssl" id="ssl"<?php if( defined('FTP_SSL') ) echo ' disabled="disabled"' ?>>
    5459<?php
    5560foreach ( array(0 => __('No'), 1 => __('Yes')) as $key => $value ) :
Note: See TracChangeset for help on using the changeset viewer.