Coding Standards: Rewrite a fragment in `request_filesystem_credentials()` for clarity and to avoid repetition.
Follow-up to [8540], [8865]. See #52627. Built from https://develop.svn.wordpress.org/trunk@50701 git-svn-id: http://core.svn.wordpress.org/trunk@50310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
82042a0377
commit
8e059f3657
|
@ -2159,14 +2159,25 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
|
|||
);
|
||||
}
|
||||
|
||||
// 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).
|
||||
$credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : ( ! empty( $submitted_form['hostname'] ) ? $submitted_form['hostname'] : $credentials['hostname'] );
|
||||
$credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : ( ! empty( $submitted_form['username'] ) ? $submitted_form['username'] : $credentials['username'] );
|
||||
$credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ( ! empty( $submitted_form['password'] ) ? $submitted_form['password'] : '' );
|
||||
$ftp_constants = array(
|
||||
'hostname' => 'FTP_HOST',
|
||||
'username' => 'FTP_USER',
|
||||
'password' => 'FTP_PASS',
|
||||
'public_key' => 'FTP_PUBKEY',
|
||||
'private_key' => 'FTP_PRIKEY',
|
||||
);
|
||||
|
||||
// Check to see if we are setting the public/private keys for ssh.
|
||||
$credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ( ! empty( $submitted_form['public_key'] ) ? $submitted_form['public_key'] : '' );
|
||||
$credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ( ! empty( $submitted_form['private_key'] ) ? $submitted_form['private_key'] : '' );
|
||||
// If defined, set it to that. Else, if POST'd, set it to that. If not, set it to an empty string.
|
||||
// Otherwise, keep it as it previously was (saved details in option).
|
||||
foreach ( $ftp_constants as $key => $constant ) {
|
||||
if ( defined( $constant ) ) {
|
||||
$credentials[ $key ] = constant( $constant );
|
||||
} elseif ( ! empty( $submitted_form[ $key ] ) ) {
|
||||
$credentials[ $key ] = $submitted_form[ $key ];
|
||||
} elseif ( ! isset( $credentials[ $key ] ) ) {
|
||||
$credentials[ $key ] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize the hostname, some people might pass in odd data.
|
||||
$credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); // Strip any schemes off.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-50700';
|
||||
$wp_version = '5.8-alpha-50701';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue