Make WordPress Core

Changeset 37467


Ignore:
Timestamp:
05/19/2016 10:58:55 PM (10 years ago)
Author:
afercia
Message:

Refine the FTP credentials form interaction.

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

Props Mte90.
Fixes #34376.

Location:
trunk/src/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/forms.css

    r37458 r37467  
    971971
    972972.request-filesystem-credentials-dialog .notification-dialog {
    973         top: 15%;
     973        top: 10%;
    974974        max-height: 85%;
    975975}
     
    10271027.request-filesystem-credentials-dialog label[for="ftp"] {
    10281028        margin-right: 10px;
     1029}
     1030
     1031.request-filesystem-credentials-dialog #auth-keys-desc {
     1032        margin-bottom: 0;
    10291033}
    10301034
  • trunk/src/wp-admin/includes/file.php

    r37421 r37467  
    11671167
    11681168?>
    1169 <script type="text/javascript">
    1170 <!--
    1171 jQuery(function($){
    1172         jQuery("#ssh").click(function () {
    1173                 jQuery("#ssh_keys").show();
    1174         });
    1175         jQuery("#ftp, #ftps").click(function () {
    1176                 jQuery("#ssh_keys").hide();
    1177         });
    1178         jQuery('#request-filesystem-credentials-form input[value=""]:first').focus();
    1179 });
    1180 -->
    1181 </script>
    11821169<form action="<?php echo esc_url( $form_post ) ?>" method="post">
    11831170<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
     
    12261213        </label>
    12271214</div>
    1228 <?php if ( isset($types['ssh']) ) : ?>
    12291215<fieldset>
     1216<legend><?php _e( 'Connection Type' ); ?></legend>
     1217<?php
     1218        $disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false );
     1219        foreach ( $types as $name => $text ) : ?>
     1220        <label for="<?php echo esc_attr( $name ) ?>">
     1221                <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; ?> />
     1222                <?php echo $text; ?>
     1223        </label>
     1224<?php
     1225        endforeach;
     1226?>
     1227</fieldset>
     1228<?php
     1229if ( isset( $types['ssh'] ) ) {
     1230        $hidden_class = '';
     1231        if ( 'ssh' != $connection_type || empty( $connection_type ) ) {
     1232                $hidden_class = ' class="hidden"';
     1233        }
     1234?>
     1235<fieldset id="ssh-keys"<?php echo $hidden_class; ?>">
    12301236<legend><?php _e( 'Authentication Keys' ); ?></legend>
    12311237<label for="public_key">
     
    12371243        <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
    12381244</label>
    1239 </fieldset>
    1240 <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>
    1241 <?php endif; ?>
    1242 <fieldset>
    1243 <legend><?php _e( 'Connection Type' ); ?></legend>
    1244 <?php
    1245         $disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
    1246         foreach ( $types as $name => $text ) : ?>
    1247         <label for="<?php echo esc_attr($name) ?>">
    1248                 <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; ?> />
    1249                 <?php echo $text ?>
    1250         </label>
    1251         <?php endforeach; ?>
     1245<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>
    12521246</fieldset>
    12531247<?php
     1248}
     1249
    12541250foreach ( (array) $extra_fields as $field ) {
    12551251        if ( isset( $_POST[ $field ] ) )
  • trunk/src/wp-admin/js/updates.js

    r36558 r37467  
    472472
    473473        $( document ).ready( function() {
     474                // Set initial focus on the first empty form field.
     475                $( '#request-filesystem-credentials-form input[value=""]:first' ).focus();
     476
    474477                /*
    475478                 * Check whether a user needs to submit filesystem credentials based on whether
     
    504507                });
    505508
    506                 // Hide SSH fields when not selected
    507                 $( '#request-filesystem-credentials-dialog input[name="connection_type"]' ).on( 'change', function() {
    508                         $( this ).parents( 'form' ).find( '#private_key, #public_key' ).parents( 'label' ).toggle( ( 'ssh' == $( this ).val() ) );
    509                 }).change();
     509                // Hide SSH fields when not selected.
     510                $( '#request-filesystem-credentials-form input[name="connection_type"]' ).on( 'change', function() {
     511                        $( '#ssh-keys' ).toggleClass( 'hidden', ( 'ssh' !== $( this ).val() ) );
     512                });
    510513
    511514                // Click handler for plugin updates in List Table view.
Note: See TracChangeset for help on using the changeset viewer.