Refine the FTP credentials form interaction.

Properly toggle SSH2 Authentication Keys fieldset visibility.
JavaScript and CSS clean-up.

Props Mte90.
Fixes #34376.
Built from https://develop.svn.wordpress.org/trunk@37467


git-svn-id: http://core.svn.wordpress.org/trunk@37435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2016-05-19 22:59:28 +00:00
parent 4a12078b31
commit ce94f2dfbd
10 changed files with 46 additions and 39 deletions

View File

@ -970,7 +970,7 @@ table.form-table td .updated p {
} }
.request-filesystem-credentials-dialog .notification-dialog { .request-filesystem-credentials-dialog .notification-dialog {
top: 15%; top: 10%;
max-height: 85%; max-height: 85%;
} }
@ -1028,6 +1028,10 @@ table.form-table td .updated p {
margin-left: 10px; margin-left: 10px;
} }
.request-filesystem-credentials-dialog #auth-keys-desc {
margin-bottom: 0;
}
#request-filesystem-credentials-dialog .button:not(:last-child) { #request-filesystem-credentials-dialog .button:not(:last-child) {
margin-left: 10px; margin-left: 10px;
} }

File diff suppressed because one or more lines are too long

View File

@ -970,7 +970,7 @@ table.form-table td .updated p {
} }
.request-filesystem-credentials-dialog .notification-dialog { .request-filesystem-credentials-dialog .notification-dialog {
top: 15%; top: 10%;
max-height: 85%; max-height: 85%;
} }
@ -1028,6 +1028,10 @@ table.form-table td .updated p {
margin-right: 10px; margin-right: 10px;
} }
.request-filesystem-credentials-dialog #auth-keys-desc {
margin-bottom: 0;
}
#request-filesystem-credentials-dialog .button:not(:last-child) { #request-filesystem-credentials-dialog .button:not(:last-child) {
margin-right: 10px; margin-right: 10px;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1166,19 +1166,6 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
$types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context ); $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
?> ?>
<script type="text/javascript">
<!--
jQuery(function($){
jQuery("#ssh").click(function () {
jQuery("#ssh_keys").show();
});
jQuery("#ftp, #ftps").click(function () {
jQuery("#ssh_keys").hide();
});
jQuery('#request-filesystem-credentials-form input[value=""]:first').focus();
});
-->
</script>
<form action="<?php echo esc_url( $form_post ) ?>" method="post"> <form action="<?php echo esc_url( $form_post ) ?>" method="post">
<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form"> <div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
<?php <?php
@ -1225,8 +1212,27 @@ echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connectio
<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em> <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
</label> </label>
</div> </div>
<?php if ( isset($types['ssh']) ) : ?>
<fieldset> <fieldset>
<legend><?php _e( 'Connection Type' ); ?></legend>
<?php
$disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false );
foreach ( $types as $name => $text ) : ?>
<label for="<?php echo esc_attr( $name ) ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $name ) ?>"<?php checked( $name, $connection_type ); echo $disabled; ?> />
<?php echo $text; ?>
</label>
<?php
endforeach;
?>
</fieldset>
<?php
if ( isset( $types['ssh'] ) ) {
$hidden_class = '';
if ( 'ssh' != $connection_type || empty( $connection_type ) ) {
$hidden_class = ' class="hidden"';
}
?>
<fieldset id="ssh-keys"<?php echo $hidden_class; ?>">
<legend><?php _e( 'Authentication Keys' ); ?></legend> <legend><?php _e( 'Authentication Keys' ); ?></legend>
<label for="public_key"> <label for="public_key">
<span class="field-title"><?php _e('Public Key:') ?></span> <span class="field-title"><?php _e('Public Key:') ?></span>
@ -1236,21 +1242,11 @@ echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connectio
<span class="field-title"><?php _e('Private Key:') ?></span> <span class="field-title"><?php _e('Private Key:') ?></span>
<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> /> <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
</label> </label>
</fieldset> <p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ) ?></p>
<span id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></span>
<?php endif; ?>
<fieldset>
<legend><?php _e( 'Connection Type' ); ?></legend>
<?php
$disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
foreach ( $types as $name => $text ) : ?>
<label for="<?php echo esc_attr($name) ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> />
<?php echo $text ?>
</label>
<?php endforeach; ?>
</fieldset> </fieldset>
<?php <?php
}
foreach ( (array) $extra_fields as $field ) { foreach ( (array) $extra_fields as $field ) {
if ( isset( $_POST[ $field ] ) ) if ( isset( $_POST[ $field ] ) )
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';

View File

@ -471,6 +471,9 @@ window.wp = window.wp || {};
$( document ).ready( function() { $( document ).ready( function() {
// Set initial focus on the first empty form field.
$( '#request-filesystem-credentials-form input[value=""]:first' ).focus();
/* /*
* Check whether a user needs to submit filesystem credentials based on whether * Check whether a user needs to submit filesystem credentials based on whether
* the form was output on the page server-side. * the form was output on the page server-side.
@ -503,10 +506,10 @@ window.wp = window.wp || {};
wp.updates.requestForCredentialsModalCancel(); wp.updates.requestForCredentialsModalCancel();
}); });
// Hide SSH fields when not selected // Hide SSH fields when not selected.
$( '#request-filesystem-credentials-dialog input[name="connection_type"]' ).on( 'change', function() { $( '#request-filesystem-credentials-form input[name="connection_type"]' ).on( 'change', function() {
$( this ).parents( 'form' ).find( '#private_key, #public_key' ).parents( 'label' ).toggle( ( 'ssh' == $( this ).val() ) ); $( '#ssh-keys' ).toggleClass( 'hidden', ( 'ssh' !== $( this ).val() ) );
}).change(); });
// Click handler for plugin updates in List Table view. // Click handler for plugin updates in List Table view.
$( '.plugin-update-tr' ).on( 'click', '.update-link', function( e ) { $( '.plugin-update-tr' ).on( 'click', '.update-link', function( e ) {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.6-alpha-37466'; $wp_version = '4.6-alpha-37467';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.