Changeset 31755
- Timestamp:
- 03/12/2015 05:50:54 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/forms.css
r31749 r31755 851 851 } 852 852 853 /*------------------------------------------------------------------------------854 Credentials check dialog for Install and Updates855 ------------------------------------------------------------------------------*/856 857 .request-filesystem-credentials-dialog {858 display: none;859 }860 861 .request-filesystem-credentials-dialog .notification-dialog{862 top: 15%863 }864 865 .request-filesystem-credentials-dialog-content{866 margin: 25px;867 }868 .request-filesystem-credentials-dialog-content input[type="text"],869 .request-filesystem-credentials-dialog-content input[type="password"]{870 width:85%;871 }872 873 853 /* =Media Queries 874 854 -------------------------------------------------------------- */ -
trunk/src/wp-admin/includes/ajax-actions.php
r31751 r31755 2914 2914 $status['error'] = $result->get_error_message(); 2915 2915 wp_send_json_error( $status ); 2916 } else if ( is_null( $result ) ) {2917 $status['errorCode'] = 'unable_to_connect_to_filesystem';2918 $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );2919 wp_send_json_error( $status );2920 2916 } 2921 2917 … … 2959 2955 $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); 2960 2956 $result = $upgrader->bulk_upgrade( array( $plugin ) ); 2957 2961 2958 if ( is_array( $result ) ) { 2962 wp_send_json_success( $status ); 2963 } else if ( is_wp_error( $result ) ) { 2959 $result = $result[ $plugin ]; 2960 } 2961 2962 if ( is_wp_error( $result ) ) { 2964 2963 $status['error'] = $result->get_error_message(); 2965 2964 wp_send_json_error( $status ); 2966 } else if ( is_bool( $result ) && ! $result ) { 2967 $status['errorCode'] = 'unable_to_connect_to_filesystem'; 2968 $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' ); 2969 wp_send_json_error( $status ); 2970 } 2965 } 2966 2967 wp_send_json_success( $status ); 2971 2968 } 2972 2969 -
trunk/src/wp-admin/js/updates.js
r31753 r31755 23 23 24 24 /** 25 * Whether filesystem credentials need to be requested from the user.25 * Flag if we're waiting for an install/update to complete. 26 26 * 27 27 * @since 4.2.0 … … 29 29 * @var bool 30 30 */ 31 wp.updates.shouldRequestFilesystemCredentials = window._wpUpdatesSettings.requestFilesystemCredentials;32 33 /**34 * Filesystem credentials to be packaged along with the request.35 *36 * @since 4.2.037 *38 * @var object39 */40 wp.updates.filesystemCredentials = {41 ftp: {42 host: null,43 username: null,44 password: null,45 connectionType: null46 },47 ssh: {48 publicKey: null,49 privateKey: null50 }51 };52 53 /**54 * Flag if we're waiting for an install/update to complete.55 *56 * @since 4.2.057 *58 * @var bool59 */60 31 wp.updates.updateLock = false; 61 62 /**63 * Flag if we've done an install or update successfully.64 *65 * @since 4.2.066 *67 * @var bool68 */69 wp.updates.updateDoneSuccessfully = false;70 32 71 33 /** … … 163 125 var data = { 164 126 '_ajax_nonce': wp.updates.ajaxNonce, 165 'plugin': plugin, 166 'slug': slug, 167 username: wp.updates.filesystemCredentials.ftp.username, 168 password: wp.updates.filesystemCredentials.ftp.password, 169 hostname: wp.updates.filesystemCredentials.ftp.hostname, 170 connection_type: wp.updates.filesystemCredentials.ftp.connectionType, 171 public_key: wp.updates.filesystemCredentials.ssh.publicKey, 172 private_key: wp.updates.filesystemCredentials.ssh.privateKey 127 'plugin': plugin, 128 'slug': slug 173 129 }; 174 130 … … 202 158 203 159 wp.updates.decrementCount( 'plugin' ); 204 205 wp.updates.updateDoneSuccessfully = true;206 160 }; 207 161 … … 215 169 wp.updates.updateError = function( response ) { 216 170 var $message; 217 wp.updates.updateDoneSuccessfully = false;218 if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {219 wp.updates.credentialError( response, 'update-plugin' );220 return;221 }222 171 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) { 223 172 $message = $( '#' + response.slug ).next().find( '.update-message' ); … … 229 178 wp.a11y.speak( wp.updates.l10n.updateFailed ); 230 179 }; 231 232 /**233 * Show an234 *235 * @param {string} message236 * @since 4.2.0237 */238 wp.updates.showErrorInCredentialsForm = function( message ) {239 var $notificationDialog = $( '.notification-dialog' );240 241 // Remove any existing error242 $notificationDialog.find( '.error' ).remove();243 244 $notificationDialog.find( 'h3' ).after( '<div class="error">' + message + '</div>' );245 };246 180 247 181 /** … … 283 217 284 218 var data = { 285 '_ajax_nonce': wp.updates.ajaxNonce, 286 'slug': slug, 287 'username': wp.updates.filesystemCredentials.ftp.username, 288 'password': wp.updates.filesystemCredentials.ftp.password, 289 'hostname': wp.updates.filesystemCredentials.ftp.hostname, 290 'connection_type': wp.updates.filesystemCredentials.ftp.connectionType, 291 'public_key': wp.updates.filesystemCredentials.ssh.publicKey, 292 'private_key': wp.updates.filesystemCredentials.ssh.privateKey 219 '_ajax_nonce': wp.updates.ajaxNonce, 220 'slug': slug 293 221 }; 294 222 … … 312 240 $message.text( wp.updates.l10n.installed ); 313 241 wp.a11y.speak( wp.updates.l10n.installedMsg ); 314 wp.updates.updateDoneSuccessfully = true;315 242 }; 316 243 … … 324 251 wp.updates.installError = function( response ) { 325 252 var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' ); 326 wp.updates.updateDoneSuccessfully = false;327 if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {328 wp.updates.credentialError( response, 'update-plugin' );329 return;330 }331 253 332 254 $message.removeClass( 'updating-message' ); 333 255 $message.text( wp.updates.l10n.installNow ); 334 };335 336 /**337 * Events that need to happen when there is a credential error338 *339 * @since 4.2.0340 */341 wp.updates.credentialError = function( response, type ) {342 wp.updates.updateQueue.push( {343 'type': type,344 'data': {345 // Not cool that we're depending on response for this data.346 // This would feel more whole in a view all tied together.347 plugin: response.plugin,348 slug: response.slug349 }350 } );351 wp.updates.showErrorInCredentialsForm( response.error );352 wp.updates.requestFilesystemCredentials();353 256 }; 354 257 … … 379 282 } 380 283 }; 381 /** 382 * Request the users filesystem credentials if we don't have them already 383 * 384 * @since 4.2.0 385 */ 386 wp.updates.requestFilesystemCredentials = function() { 387 if ( wp.updates.updateDoneSuccessfully === false ) { 388 wp.updates.updateLock = true; 389 $( 'body' ).addClass( 'modal-open' ); 390 $( '#request-filesystem-credentials-dialog' ).show(); 391 } 392 }; 393 394 // Bind various click handlers. 284 395 285 $( document ).ready( function() { 396 // File system credentials form submit noop-er / handler.397 $( '#request-filesystem-credentials-dialog form' ).on( 'submit', function() {398 // Persist the credentials input by the user for the duration of the page load.399 wp.updates.filesystemCredentials.ftp.hostname = $('#hostname').val();400 wp.updates.filesystemCredentials.ftp.username = $('#username').val();401 wp.updates.filesystemCredentials.ftp.password = $('#password').val();402 wp.updates.filesystemCredentials.ftp.connectionType = $('input[name="connection_type"]:checked').val();403 wp.updates.filesystemCredentials.ssh.publicKey = $('#public_key').val();404 wp.updates.filesystemCredentials.ssh.privateKey = $('#private_key').val();405 406 $( '#request-filesystem-credentials-dialog' ).hide();407 $( 'body' ).removeClass( 'modal-open' );408 409 // Unlock and invoke the queue.410 wp.updates.updateLock = false;411 wp.updates.queueChecker();412 413 return false;414 });415 416 // Click handler for plugin updates in List Table view.417 286 $( '.plugin-update-tr .update-link' ).on( 'click', function( e ) { 418 287 e.preventDefault(); 419 if ( wp.updates.shouldRequestFilesystemCredentials === '1' && ! wp.updates.updateLock ) {420 wp.updates.requestFilesystemCredentials();421 }422 288 var $row = $( e.target ).parents( '.plugin-update-tr' ); 423 289 wp.updates.updatePlugin( $row.data( 'plugin' ), $row.data( 'slug' ) ); … … 450 316 $( '.plugin-card .install-now' ).on( 'click', function( e ) { 451 317 e.preventDefault(); 452 if ( wp.updates.shouldRequestFilesystemCredentials === '1' && ! wp.updates.updateLock ) {453 wp.updates.requestFilesystemCredentials();454 }455 456 318 var $button = $( e.target ); 457 319 if ( $button.hasClass( 'button-disabled' ) ) { -
trunk/src/wp-admin/plugin-install.php
r31749 r31755 129 129 do_action( "install_plugins_$tab", $paged ); ?> 130 130 </div> 131 132 <div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">133 <div class="notification-dialog-background"></div>134 <div class="notification-dialog">135 <div class="request-filesystem-credentials-dialog-content">136 <?php request_filesystem_credentials( site_url() ); ?>137 <div>138 </div>139 </div>140 141 131 <?php 142 132 /** -
trunk/src/wp-admin/plugins.php
r31749 r31755 476 476 </div> 477 477 478 <div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">479 <div class="notification-dialog-background"></div>480 <div class="notification-dialog">481 <div class="request-filesystem-credentials-dialog-content">482 <?php request_filesystem_credentials( site_url() ); ?>483 <div>484 </div>485 </div>486 478 <?php 487 479 include(ABSPATH . 'wp-admin/admin-footer.php'); -
trunk/src/wp-includes/script-loader.php
r31750 r31755 543 543 544 544 $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) ); 545 546 /*547 * Determine whether the user will need to enter filesystem credentials548 * on the front-end.549 */550 require_once(ABSPATH . 'wp-admin/includes/file.php');551 $filesystem_method = get_filesystem_method();552 ob_start();553 $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );554 ob_end_clean();555 $request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored ) ? 1 : 0;556 557 545 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array( 558 546 'ajax_nonce' => wp_create_nonce( 'updates' ), 559 'requestFilesystemCredentials' => $request_filesystem_credentials,560 547 'l10n' => array( 561 548 'updating' => __( 'Updating...' ),
Note: See TracChangeset
for help on using the changeset viewer.