WordPress.org

Make WordPress Core

Ticket #34376: 34376.3.patch

File 34376.3.patch, 4.4 KB (added by Mte90, 4 years ago)

improvement after dev-feedback

  • src/wp-admin/includes/file.php

     
    11631163        $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
    11641164
    11651165?>
    1166 <script type="text/javascript">
    1167 <!--
    1168 jQuery(function($){
    1169         jQuery("#ssh").click(function () {
    1170                 jQuery("#ssh_keys").show();
    1171         });
    1172         jQuery("#ftp, #ftps").click(function () {
    1173                 jQuery("#ssh_keys").hide();
    1174         });
    1175         jQuery('#request-filesystem-credentials-form input[value=""]:first').focus();
    1176 });
    1177 -->
    1178 </script>
    11791166<form action="<?php echo esc_url( $form_post ) ?>" method="post">
    11801167<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
    11811168<?php
     
    12221209                <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
    12231210        </label>
    12241211</div>
     1212<fieldset>
     1213<legend><?php _e( 'Connection Type' ); ?></legend>
     1214<?php
     1215        $disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
     1216        foreach ( $types as $name => $text ) : ?>
     1217        <label for="<?php echo esc_attr($name) ?>">
     1218                <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; ?> />
     1219                <?php echo $text ?>
     1220        </label>
     1221        <?php endforeach; ?>
     1222</fieldset>
    12251223<?php if ( isset($types['ssh']) ) : ?>
    1226 <fieldset>
     1224<fieldset id="ssh_keys" style="<?php if ( 'ssh' != $connection_type || empty( $connection_type ) ) echo 'display:none' ?>">
    12271225<legend><?php _e( 'Authentication Keys' ); ?></legend>
     1226<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><br/>
    12281227<label for="public_key">
    12291228        <span class="field-title"><?php _e('Public Key:') ?></span>
    12301229        <input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> />
     
    12341233        <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
    12351234</label>
    12361235</fieldset>
    1237 <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>
    12381236<?php endif; ?>
    1239 <fieldset>
    1240 <legend><?php _e( 'Connection Type' ); ?></legend>
    12411237<?php
    1242         $disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
    1243         foreach ( $types as $name => $text ) : ?>
    1244         <label for="<?php echo esc_attr($name) ?>">
    1245                 <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; ?> />
    1246                 <?php echo $text ?>
    1247         </label>
    1248         <?php endforeach; ?>
    1249 </fieldset>
    1250 <?php
    12511238foreach ( (array) $extra_fields as $field ) {
    12521239        if ( isset( $_POST[ $field ] ) )
    12531240                echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />';
  • src/wp-admin/js/updates.js

     
    471471
    472472
    473473        $( document ).ready( function() {
     474                jQuery('#request-filesystem-credentials-form input[value=""]:first').focus();
    474475                /*
    475476                 * Check whether a user needs to submit filesystem credentials based on whether
    476477                 * the form was output on the page server-side.
     
    504505                });
    505506
    506507                // 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();
     508                $( '#request-filesystem-credentials-form input[name="connection_type"]' ).on( 'change', function() {
     509                        $( this ).parents( 'form' ).find( '#ssh_keys' ).toggle( ( 'ssh' === $( this ).val() ) );
     510                });
    510511
    511512                // Click handler for plugin updates in List Table view.
    512513                $( '.plugin-update-tr' ).on( 'click', '.update-link', function( e ) {