<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[31749] trunk/src: Request FTP and SSH credentials when needed during shiny updates</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/31749">31749</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/31749","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>jorbin</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-03-12 08:52:42 +0000 (Thu, 12 Mar 2015)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Request FTP and SSH credentials when needed during shiny updates

This is a first pass at requesting FTP and SSH credentials when needed during shiny updates. Styling and some UX improvements are still needed, but we do show the prompt and use the passed data when doing plugin installs and updates for shiny updates.  There are also a couple of areas that we could improve code wise such how we create the requestFilesystemCredentials part of the localized _wpUpdatesSettings. Over the past half century, we've split the atom, we've spliced the gene and we've roamed Tranquility Base. We've reached for the stars and never have we been closer to having them in our grasp. That has nothing to do with shiny updates. 

Props ericlewis, jorbin, and drewapicture for testing
Fixes <a href="https://core.trac.wordpress.org/ticket/31528">#31528</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincssformscss">trunk/src/wp-admin/css/forms.css</a></li>
<li><a href="#trunksrcwpadminincludesajaxactionsphp">trunk/src/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunksrcwpadminjsupdatesjs">trunk/src/wp-admin/js/updates.js</a></li>
<li><a href="#trunksrcwpadminplugininstallphp">trunk/src/wp-admin/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminpluginsphp">trunk/src/wp-admin/plugins.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincssformscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/forms.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/forms.css  2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-admin/css/forms.css    2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -850,6 +850,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">        margin-bottom: 5px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/*------------------------------------------------------------------------------
+   Credentials check dialog for Install and Updates
+------------------------------------------------------------------------------*/
+
+.request-filesystem-credentials-dialog {
+       display: none;
+}
+
+.request-filesystem-credentials-dialog .notification-dialog{
+       top: 15%
+}
+
+.request-filesystem-credentials-dialog-content{
+       margin: 25px;
+}
+.request-filesystem-credentials-dialog-content input[type="text"],
+.request-filesystem-credentials-dialog-content input[type="password"]{
+       width:85%;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* =Media Queries
</span><span class="cx" style="display: block; padding: 0 10px"> -------------------------------------------------------------- */
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/ajax-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/ajax-actions.php      2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-admin/includes/ajax-actions.php        2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2913,6 +2913,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">        if ( is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $status['error'] = $result->get_error_message();
</span><span class="cx" style="display: block; padding: 0 10px">                wp_send_json_error( $status );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        } else if ( is_null( $result ) ) {
+               $status['errorCode'] = __( 'unable_to_connect_to_filesystem' );
+               $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
+               wp_send_json_error( $status );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $plugin_status = install_plugin_install_status( $api );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2954,17 +2958,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
</span><span class="cx" style="display: block; padding: 0 10px">        $result = $upgrader->bulk_upgrade( array( $plugin ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">         if ( is_array( $result ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $result = $result[ $plugin ];
-       }
-
-       if ( is_wp_error( $result ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_send_json_success( $status );
+       } else if ( is_wp_error( $result ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $status['error'] = $result->get_error_message();
</span><span class="cx" style="display: block; padding: 0 10px">                wp_send_json_error( $status );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        } else if ( is_bool( $result ) && ! $result ) {
+               $status['errorCode'] = __( 'unable_to_connect_to_filesystem' );
+               $status['error'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
+               wp_send_json_error( $status );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       wp_send_json_success( $status );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpadminjsupdatesjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/updates.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/updates.js  2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-admin/js/updates.js    2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,6 +22,35 @@
</span><span class="cx" style="display: block; padding: 0 10px">        wp.updates.l10n = window._wpUpdatesSettings.l10n;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Whether filesystem credentials need to be requested from the user.
+        *
+        * @since 4.2.0
+        *
+        * @var bool
+        */
+       wp.updates.shouldRequestFilesystemCredentials = window._wpUpdatesSettings.requestFilesystemCredentials;
+
+       /**
+        * Filesystem credentials to be packaged along with the request.
+        *
+        * @since  4.2.0
+        *
+        * @var object
+        */
+       wp.updates.filesystemCredentials = {
+               ftp: {
+                       host: null,
+                       username: null,
+                       password: null,
+                       connectionType: null
+               },
+               ssh: {
+                       publicKey: null,
+                       privateKey: null
+               }
+       };
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Flag if we're waiting for an install/update to complete.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 4.2.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,6 +60,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">        wp.updates.updateLock = false;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Flag if we've done an install or update successfully.
+        *
+        * @since 4.2.0
+        *
+        * @var bool
+        */
+       wp.updates.updateDoneSuccessfully = false;
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * If the user tries to install/update a plugin while an install/update is
</span><span class="cx" style="display: block; padding: 0 10px">         * already happening, it can be placed in this queue to perform later.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -124,8 +162,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                var data = {
</span><span class="cx" style="display: block; padding: 0 10px">                        '_ajax_nonce': wp.updates.ajaxNonce,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'plugin':      plugin,
-                       'slug':        slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'plugin':        plugin,
+                       'slug':          slug,
+                       username:        wp.updates.filesystemCredentials.ftp.username,
+                       password:        wp.updates.filesystemCredentials.ftp.password,
+                       hostname:        wp.updates.filesystemCredentials.ftp.hostname,
+                       connection_type: wp.updates.filesystemCredentials.ftp.connectionType,
+                       public_key:      wp.updates.filesystemCredentials.ssh.publicKey,
+                       private_key:     wp.updates.filesystemCredentials.ssh.privateKey
</ins><span class="cx" style="display: block; padding: 0 10px">                 };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                wp.ajax.post( 'update-plugin', data )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,6 +201,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp.a11y.speak( wp.updates.l10n.updatedMsg );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                wp.updates.decrementCount( 'plugin' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               wp.updates.updateDoneSuccessfully = true;
</ins><span class="cx" style="display: block; padding: 0 10px">         };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,6 +214,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        wp.updates.updateError = function( response ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var $message;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                wp.updates.updateDoneSuccessfully = false;
+               if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {
+                       wp.updates.credentialError( response, 'update-plugin' );
+                       return;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 'plugins' === pagenow || 'plugins-network' === pagenow ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $message = $( '#' + response.slug ).next().find( '.update-message' );
</span><span class="cx" style="display: block; padding: 0 10px">                } else if ( 'plugin-install' === pagenow ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,6 +230,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Show an
+        *
+        * @param {string} message
+        * @since 4.2.0
+        */
+       wp.updates.showErrorInCredentialsForm = function( message ) {
+               var $notificationDialog = $( '.notification-dialog' );
+
+               // Remove any existing error
+               $notificationDialog.find( '.error' ).remove();
+
+               $notificationDialog.find( 'h3' ).after( '<div class="error">' + message + '</div>' );
+    };
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * After an update attempt has completed, check the queue.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 4.2.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,8 +282,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp.updates.updateLock = true;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                var data = {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        '_ajax_nonce': wp.updates.ajaxNonce,
-                       'slug':        slug
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 '_ajax_nonce':     wp.updates.ajaxNonce,
+                       'slug':            slug,
+                       'username':        wp.updates.filesystemCredentials.ftp.username,
+                       'password':        wp.updates.filesystemCredentials.ftp.password,
+                       'hostname':        wp.updates.filesystemCredentials.ftp.hostname,
+                       'connection_type': wp.updates.filesystemCredentials.ftp.connectionType,
+                       'public_key':      wp.updates.filesystemCredentials.ssh.publicKey,
+                       'private_key':     wp.updates.filesystemCredentials.ssh.privateKey
</ins><span class="cx" style="display: block; padding: 0 10px">                 };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                wp.ajax.post( 'install-plugin', data )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -239,6 +311,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $message.removeClass( 'updating-message' ).addClass( 'updated-message button-disabled' );
</span><span class="cx" style="display: block; padding: 0 10px">                $message.text( wp.updates.l10n.installed );
</span><span class="cx" style="display: block; padding: 0 10px">                wp.a11y.speak( wp.updates.l10n.installedMsg );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                wp.updates.updateDoneSuccessfully = true;
</ins><span class="cx" style="display: block; padding: 0 10px">         };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -250,12 +323,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        wp.updates.installError = function( response ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                wp.updates.updateDoneSuccessfully = false;
+               if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {
+                       wp.updates.credentialError( response, 'update-plugin' );
+                       return;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $message.removeClass( 'updating-message' );
</span><span class="cx" style="display: block; padding: 0 10px">                $message.text( wp.updates.l10n.installNow );
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Events that need to happen when there is a credential error
+        *
+        * @since 4.2.0
+        */
+       wp.updates.credentialError = function( response, type ) {
+               wp.updates.updateQueue.push( {
+                       'type': type,
+                       'data': {
+                               // Not cool that we're depending on response for this data.
+                               // This would feel more whole in a view all tied together.
+                               plugin: response.plugin,
+                               slug: response.slug
+                       }
+               } );
+               wp.updates.showErrorInCredentialsForm( response.error );
+               wp.updates.requestFilesystemCredentials();
+       };
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * If an install/update job has been placed in the queue, queueChecker pulls it out and runs it.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,10 +378,45 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Request the users filesystem credentials if we don't have them already
+        *
+        * @since 4.2.0
+        */
+       wp.updates.requestFilesystemCredentials = function() {
+               if ( wp.updates.updateDoneSuccessfully === false ) {
+                       wp.updates.updateLock = true;
+                       $('#request-filesystem-credentials-dialog').show();
+               }
+       };
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // Bind various click handlers.
</ins><span class="cx" style="display: block; padding: 0 10px">         $( document ).ready( function() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // File system credentials form submit noop-er / handler.
+               $('#request-filesystem-credentials-dialog form').on( 'submit', function() {
+                       // Persist the credentials input by the user for the duration of the page load.
+                       wp.updates.filesystemCredentials.ftp.hostname = $('#hostname').val();
+                       wp.updates.filesystemCredentials.ftp.username = $('#username').val();
+                       wp.updates.filesystemCredentials.ftp.password = $('#password').val();
+                       wp.updates.filesystemCredentials.ftp.connectionType = $('input[name="connection_type"]:checked').val();
+                       wp.updates.filesystemCredentials.ssh.publicKey = $('#public_key').val();
+                       wp.updates.filesystemCredentials.ssh.privateKey = $('#private_key').val();
+
+                       $('#request-filesystem-credentials-dialog').hide();
+
+                       // Unlock and invoke the queue.
+                       wp.updates.updateLock = false;
+                       wp.updates.queueChecker();
+
+                       return false;
+               });
+
+               // Click handler for plugin updates in List Table view.
</ins><span class="cx" style="display: block; padding: 0 10px">                 $( '.plugin-update-tr .update-link' ).on( 'click', function( e ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        e.preventDefault();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        if ( wp.updates.shouldRequestFilesystemCredentials === '1' && ! wp.updates.updateLock ) {
+                               wp.updates.requestFilesystemCredentials();
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                         var $row = $( e.target ).parents( '.plugin-update-tr' );
</span><span class="cx" style="display: block; padding: 0 10px">                        wp.updates.updatePlugin( $row.data( 'plugin' ), $row.data( 'slug' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,6 +447,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $( '.plugin-card .install-now' ).on( 'click', function( e ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        e.preventDefault();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        if ( wp.updates.shouldRequestFilesystemCredentials === '1' && ! wp.updates.updateLock ) {
+                               wp.updates.requestFilesystemCredentials();
+                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         var $button = $( e.target );
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $button.hasClass( 'button-disabled' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span></span></pre></div>
<a id="trunksrcwpadminplugininstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugin-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugin-install.php     2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-admin/plugin-install.php       2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,6 +128,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( "install_plugins_$tab", $paged ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+<div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">
+       <div class="notification-dialog-background"></div>
+       <div class="notification-dialog">
+               <div class="request-filesystem-credentials-dialog-content">
+                       <?php request_filesystem_credentials( site_url() ); ?>
+               <div>
+       </div>
+</div>
+
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * WordPress Administration Template Footer.
</span></span></pre></div>
<a id="trunksrcwpadminpluginsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/plugins.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/plugins.php    2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-admin/plugins.php      2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -475,5 +475,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<div id="request-filesystem-credentials-dialog" class="notification-dialog-wrap request-filesystem-credentials-dialog">
+       <div class="notification-dialog-background"></div>
+       <div class="notification-dialog">
+               <div class="request-filesystem-credentials-dialog-content">
+                       <?php request_filesystem_credentials( site_url() ); ?>
+               <div>
+       </div>
+</div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> include(ABSPATH . 'wp-admin/admin-footer.php');
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php   2015-03-12 06:14:53 UTC (rev 31748)
+++ trunk/src/wp-includes/script-loader.php     2015-03-12 08:52:42 UTC (rev 31749)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -542,8 +542,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               /*
+                * Determine whether the user will need to enter filesystem credentials
+                * on the front-end.
+                */
+               require_once(ABSPATH . 'wp-admin/includes/file.php');
+               $filesystem_method = get_filesystem_method();
+               ob_start();
+               $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() );
+               ob_end_clean();
+               $request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored ) ? 1 : 0;
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 did_action( 'init' ) && $scripts->localize( 'updates', '_wpUpdatesSettings', array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'ajax_nonce' => wp_create_nonce( 'updates' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        'requestFilesystemCredentials' => $request_filesystem_credentials,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'l10n'       => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'updating'      => __( 'Updating...' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                'updated'       => __( 'Updated!' ),
</span></span></pre>
</div>
</div>

</body>
</html>