diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index 9c97317a92..b272d570d6 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -2876,57 +2876,6 @@ function wp_ajax_destroy_sessions() {
wp_send_json_success( array( 'message' => $message ) );
}
-/**
- * AJAX handler for installing a plugin.
- *
- * @since 4.2.0
- */
-function wp_ajax_install_plugin() {
- $status = array(
- 'install' => 'plugin',
- 'slug' => sanitize_key( $_POST['slug'] ),
- );
-
- if ( ! current_user_can( 'install_plugins' ) ) {
- $status['error'] = __( 'You do not have sufficient permissions to install plugins on this site.' );
- wp_send_json_error( $status );
- }
-
- check_ajax_referer( 'updates' );
-
- include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
- include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
-
- $api = plugins_api( 'plugin_information', array(
- 'slug' => sanitize_key( $_POST['slug'] ),
- 'fields' => array( 'sections' => false )
- ) );
-
- if ( is_wp_error( $api ) ) {
- $status['error'] = $api->get_error_message();
- wp_send_json_error( $status );
- }
-
- $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
- $result = $upgrader->install( $api->download_link );
-
- if ( is_wp_error( $result ) ) {
- $status['error'] = $result->get_error_message();
- wp_send_json_error( $status );
- } 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 );
- }
-
- $plugin_status = install_plugin_install_status( $api );
-
- if ( ! is_multisite() ) {
- activate_plugin( $plugin_status['file'] );
- }
-
- wp_send_json_success( $status );
-}
/**
* AJAX handler for updating a plugin.
diff --git a/wp-admin/js/updates.js b/wp-admin/js/updates.js
index 77f0399486..85e044f643 100644
--- a/wp-admin/js/updates.js
+++ b/wp-admin/js/updates.js
@@ -51,7 +51,7 @@ window.wp = window.wp || {};
};
/**
- * Flag if we're waiting for an install/update to complete.
+ * Flag if we're waiting for an update to complete.
*
* @since 4.2.0
*
@@ -60,7 +60,7 @@ window.wp = window.wp || {};
wp.updates.updateLock = false;
/**
- * * Flag if we've done an install or update successfully.
+ * * Flag if we've done an update successfully.
*
* @since 4.2.0
*
@@ -69,7 +69,7 @@ window.wp = window.wp || {};
wp.updates.updateDoneSuccessfully = false;
/**
- * If the user tries to install/update a plugin while an install/update is
+ * If the user tries to update a plugin while an update is
* already happening, it can be placed in this queue to perform later.
*
* @since 4.2.0
@@ -255,92 +255,6 @@ window.wp = window.wp || {};
$notificationDialog.find( 'h3' ).after( '
' + message + '
' );
};
- /**
- * Send an Ajax request to the server to install a plugin.
- *
- * @since 4.2.0
- *
- * @param {string} slug
- */
- wp.updates.installPlugin = function( slug ) {
- var $message = $( '.plugin-card-' + slug ).find( '.install-now' );
-
- $message.addClass( 'updating-message' );
- $message.text( wp.updates.l10n.installing );
- wp.a11y.speak( wp.updates.l10n.installingMsg );
-
- if ( wp.updates.updateLock ) {
- wp.updates.updateQueue.push( {
- type: 'install-plugin',
- data: {
- slug: slug
- }
- } );
- return;
- }
-
- wp.updates.updateLock = true;
-
- var data = {
- _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
- };
-
- wp.ajax.post( 'install-plugin', data )
- .done( wp.updates.installSuccess )
- .fail( wp.updates.installError );
- };
-
- /**
- * On plugin install success, update the UI with the result.
- *
- * @since 4.2.0
- *
- * @param {object} response
- */
- wp.updates.installSuccess = function( response ) {
- var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
-
- $message.removeClass( 'updating-message' ).addClass( 'updated-message button-disabled' );
- $message.text( wp.updates.l10n.installed );
- wp.a11y.speak( wp.updates.l10n.installedMsg );
- wp.updates.updateDoneSuccessfully = true;
-
- /*
- * The lock can be released since the update was successful,
- * and any other updates can commence.
- */
- wp.updates.updateLock = false;
- wp.updates.queueChecker();
- };
-
- /**
- * On plugin install failure, update the UI appropriately.
- *
- * @since 4.2.0
- *
- * @param {object} response
- */
- wp.updates.installError = function( response ) {
- var $message = $( '.plugin-card-' + response.slug ).find( '.install-now' );
- wp.updates.updateDoneSuccessfully = false;
- if ( response.errorCode && response.errorCode == 'unable_to_connect_to_filesystem' ) {
- wp.updates.credentialError( response, 'install-plugin' );
- return;
- }
-
- $message.removeClass( 'updating-message' );
- $message.text( wp.updates.l10n.installNow );
-
- wp.updates.updateLock = false;
- };
-
/**
* Events that need to happen when there is a credential error
*
@@ -361,7 +275,7 @@ window.wp = window.wp || {};
};
/**
- * If an install/update job has been placed in the queue, queueChecker pulls it out and runs it.
+ * If an update job has been placed in the queue, queueChecker pulls it out and runs it.
*
* @since 4.2.0
*/
@@ -372,13 +286,13 @@ window.wp = window.wp || {};
var job = wp.updates.updateQueue.shift();
+ /* This normally wouldn't be a switch, but is there since updates and installs
+ originally were developed together. Kept as a switch to help with bringing
+ installs back in and to preserve commit history. */
switch ( job.type ) {
case 'update-plugin':
wp.updates.updatePlugin( job.data.plugin, job.data.slug );
break;
- case 'install-plugin':
- wp.updates.installPlugin( job.data.slug );
- break;
default:
window.console.log( 'Failed to exect queued update job.' );
window.console.log( job );
@@ -463,17 +377,6 @@ window.wp = window.wp || {};
wp.updates.updatePlugin( $button.data( 'plugin' ), $button.data( 'slug' ) );
} );
- $( '.plugin-card .install-now' ).on( 'click', function( e ) {
- e.preventDefault();
- if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.updateLock ) {
- wp.updates.requestFilesystemCredentials();
- }
- var $button = $( e.target );
- if ( $button.hasClass( 'button-disabled' ) ) {
- return;
- }
- wp.updates.installPlugin( $button.data( 'slug' ) );
- } );
} );
$( window ).on( 'message', function( e ) {
diff --git a/wp-admin/js/updates.min.js b/wp-admin/js/updates.min.js
index e39fca120f..f8e8a83875 100644
--- a/wp-admin/js/updates.min.js
+++ b/wp-admin/js/updates.min.js
@@ -1 +1 @@
-window.wp=window.wp||{},function(a,b,c){b.updates={},b.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,b.updates.l10n=window._wpUpdatesSettings.l10n,b.updates.shouldRequestFilesystemCredentials=null,b.updates.filesystemCredentials={ftp:{host:null,username:null,password:null,connectionType:null},ssh:{publicKey:null,privateKey:null}},b.updates.updateLock=!1,b.updates.updateDoneSuccessfully=!1,b.updates.updateQueue=[],b.updates.decrementCount=function(b){var c,d,e=a("#wp-admin-bar-updates .ab-label"),f=a('a[href="update-core.php"] .update-plugins'),g=a("#menu-plugins");if(c=e.text(),c=parseInt(c,10)-1,!(0>c||isNaN(c))&&(a("#wp-admin-bar-updates .ab-item").removeAttr("title"),e.text(c),f.each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+c)}),f.removeAttr("title"),f.find(".update-count").text(c),"plugin"===b)){if(d=g.find(".plugin-count").eq(0).text(),d=parseInt(d,10)-1,0>d||isNaN(d))return;g.find(".plugin-count").text(d),g.find(".update-plugins").each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+d)}),d>0?a(".subsubsub .upgrade .count").text("("+d+")"):a(".subsubsub .upgrade").remove()}},b.updates.updatePlugin=function(d,e){var f;if("plugins"===c||"plugins-network"===c?f=a('[data-slug="'+e+'"]').next().find(".update-message"):"plugin-install"===c&&(f=a(".plugin-card-"+e).find(".update-now")),f.addClass("updating-message"),f.text(b.updates.l10n.updating),b.a11y.speak(b.updates.l10n.updatingMsg),b.updates.updateLock)return void b.updates.updateQueue.push({type:"update-plugin",data:{plugin:d,slug:e}});b.updates.updateLock=!0;var g={_ajax_nonce:b.updates.ajaxNonce,plugin:d,slug:e,username:b.updates.filesystemCredentials.ftp.username,password:b.updates.filesystemCredentials.ftp.password,hostname:b.updates.filesystemCredentials.ftp.hostname,connection_type:b.updates.filesystemCredentials.ftp.connectionType,public_key:b.updates.filesystemCredentials.ssh.publicKey,private_key:b.updates.filesystemCredentials.ssh.privateKey};b.ajax.post("update-plugin",g).done(b.updates.updateSuccess).fail(b.updates.updateError)},b.updates.updateSuccess=function(d){var e;if("plugins"===c||"plugins-network"===c){var f=a('[data-slug="'+d.slug+'"]').first();e=f.next().find(".update-message"),f.addClass("updated").removeClass("update");var g=f.find(".plugin-version-author-uri").html().replace(d.oldVersion,d.newVersion);f.find(".plugin-version-author-uri").html(g)}else"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now"),e.addClass("button-disabled"));e.removeClass("updating-message").addClass("updated-message"),e.text(b.updates.l10n.updated),b.a11y.speak(b.updates.l10n.updatedMsg),b.updates.decrementCount("plugin"),b.updates.updateDoneSuccessfully=!0,b.updates.updateLock=!1,b.updates.queueChecker()},b.updates.updateError=function(d){var e;return b.updates.updateDoneSuccessfully=!1,d.errorCode&&"unable_to_connect_to_filesystem"==d.errorCode?void b.updates.credentialError(d,"update-plugin"):("plugins"===c||"plugins-network"===c?e=a('[data-slug="'+d.slug+'"]').next().find(".update-message"):"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now")),e.removeClass("updating-message"),e.text(b.updates.l10n.updateFailed),void b.a11y.speak(b.updates.l10n.updateFailed))},b.updates.showErrorInCredentialsForm=function(b){var c=a(".notification-dialog");c.find(".error").remove(),c.find("h3").after(''+b+"
")},b.updates.installPlugin=function(c){var d=a(".plugin-card-"+c).find(".install-now");if(d.addClass("updating-message"),d.text(b.updates.l10n.installing),b.a11y.speak(b.updates.l10n.installingMsg),b.updates.updateLock)return void b.updates.updateQueue.push({type:"install-plugin",data:{slug:c}});b.updates.updateLock=!0;var e={_ajax_nonce:b.updates.ajaxNonce,slug:c,username:b.updates.filesystemCredentials.ftp.username,password:b.updates.filesystemCredentials.ftp.password,hostname:b.updates.filesystemCredentials.ftp.hostname,connection_type:b.updates.filesystemCredentials.ftp.connectionType,public_key:b.updates.filesystemCredentials.ssh.publicKey,private_key:b.updates.filesystemCredentials.ssh.privateKey};b.ajax.post("install-plugin",e).done(b.updates.installSuccess).fail(b.updates.installError)},b.updates.installSuccess=function(c){var d=a(".plugin-card-"+c.slug).find(".install-now");d.removeClass("updating-message").addClass("updated-message button-disabled"),d.text(b.updates.l10n.installed),b.a11y.speak(b.updates.l10n.installedMsg),b.updates.updateDoneSuccessfully=!0,b.updates.updateLock=!1,b.updates.queueChecker()},b.updates.installError=function(c){var d=a(".plugin-card-"+c.slug).find(".install-now");return b.updates.updateDoneSuccessfully=!1,c.errorCode&&"unable_to_connect_to_filesystem"==c.errorCode?void b.updates.credentialError(c,"install-plugin"):(d.removeClass("updating-message"),d.text(b.updates.l10n.installNow),void(b.updates.updateLock=!1))},b.updates.credentialError=function(a,c){b.updates.updateQueue.push({type:c,data:{plugin:a.plugin,slug:a.slug}}),b.updates.showErrorInCredentialsForm(a.error),b.updates.requestFilesystemCredentials()},b.updates.queueChecker=function(){if(!(b.updates.updateLock||b.updates.updateQueue.length<=0)){var a=b.updates.updateQueue.shift();switch(a.type){case"update-plugin":b.updates.updatePlugin(a.data.plugin,a.data.slug);break;case"install-plugin":b.updates.installPlugin(a.data.slug);break;default:window.console.log("Failed to exect queued update job."),window.console.log(a)}}},b.updates.requestFilesystemCredentials=function(){b.updates.updateDoneSuccessfully===!1&&(b.updates.updateLock=!0,a("body").addClass("modal-open"),a("#request-filesystem-credentials-dialog").show())},a(document).ready(function(){b.updates.shouldRequestFilesystemCredentials=a("#request-filesystem-credentials-dialog").length<=0?!1:!0,a("#request-filesystem-credentials-dialog form").on("submit",function(){return b.updates.filesystemCredentials.ftp.hostname=a("#hostname").val(),b.updates.filesystemCredentials.ftp.username=a("#username").val(),b.updates.filesystemCredentials.ftp.password=a("#password").val(),b.updates.filesystemCredentials.ftp.connectionType=a('input[name="connection_type"]:checked').val(),b.updates.filesystemCredentials.ssh.publicKey=a("#public_key").val(),b.updates.filesystemCredentials.ssh.privateKey=a("#private_key").val(),a("#request-filesystem-credentials-dialog").hide(),a("body").removeClass("modal-open"),b.updates.updateLock=!1,b.updates.queueChecker(),!1}),a(".plugin-update-tr .update-link").on("click",function(c){c.preventDefault(),b.updates.shouldRequestFilesystemCredentials&&!b.updates.updateLock&&b.updates.requestFilesystemCredentials();var d=a(c.target).parents(".plugin-update-tr");b.updates.updatePlugin(d.data("plugin"),d.data("slug"))}),a("#bulk-action-form").on("submit",function(c){var d,e,f;"update-selected"==a("#bulk-action-selector-top").val()&&(c.preventDefault(),a('input[name="checked[]"]:checked').each(function(c,g){d=a(g),e=d.val(),f=d.parents("tr").prop("id"),b.updates.updatePlugin(e,f),d.attr("checked",!1)}))}),a(".plugin-card .update-now").on("click",function(c){c.preventDefault();var d=a(c.target);b.updates.updatePlugin(d.data("plugin"),d.data("slug"))}),a(".plugin-card .install-now").on("click",function(c){c.preventDefault(),b.updates.shouldRequestFilesystemCredentials&&!b.updates.updateLock&&b.updates.requestFilesystemCredentials();var d=a(c.target);d.hasClass("button-disabled")||b.updates.installPlugin(d.data("slug"))})}),a(window).on("message",function(c){var d,e=c.originalEvent,f=document.location,g=f.protocol+"//"+f.hostname;e.origin===g&&(d=a.parseJSON(e.data),"undefined"!=typeof d.action&&"decrementUpdateCount"===d.action&&b.updates.decrementCount(d.upgradeType))})}(jQuery,window.wp,window.pagenow,window.ajaxurl);
\ No newline at end of file
+window.wp=window.wp||{},function(a,b,c){b.updates={},b.updates.ajaxNonce=window._wpUpdatesSettings.ajax_nonce,b.updates.l10n=window._wpUpdatesSettings.l10n,b.updates.shouldRequestFilesystemCredentials=null,b.updates.filesystemCredentials={ftp:{host:null,username:null,password:null,connectionType:null},ssh:{publicKey:null,privateKey:null}},b.updates.updateLock=!1,b.updates.updateDoneSuccessfully=!1,b.updates.updateQueue=[],b.updates.decrementCount=function(b){var c,d,e=a("#wp-admin-bar-updates .ab-label"),f=a('a[href="update-core.php"] .update-plugins'),g=a("#menu-plugins");if(c=e.text(),c=parseInt(c,10)-1,!(0>c||isNaN(c))&&(a("#wp-admin-bar-updates .ab-item").removeAttr("title"),e.text(c),f.each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+c)}),f.removeAttr("title"),f.find(".update-count").text(c),"plugin"===b)){if(d=g.find(".plugin-count").eq(0).text(),d=parseInt(d,10)-1,0>d||isNaN(d))return;g.find(".plugin-count").text(d),g.find(".update-plugins").each(function(a,b){b.className=b.className.replace(/count-\d+/,"count-"+d)}),d>0?a(".subsubsub .upgrade .count").text("("+d+")"):a(".subsubsub .upgrade").remove()}},b.updates.updatePlugin=function(d,e){var f;if("plugins"===c||"plugins-network"===c?f=a('[data-slug="'+e+'"]').next().find(".update-message"):"plugin-install"===c&&(f=a(".plugin-card-"+e).find(".update-now")),f.addClass("updating-message"),f.text(b.updates.l10n.updating),b.a11y.speak(b.updates.l10n.updatingMsg),b.updates.updateLock)return void b.updates.updateQueue.push({type:"update-plugin",data:{plugin:d,slug:e}});b.updates.updateLock=!0;var g={_ajax_nonce:b.updates.ajaxNonce,plugin:d,slug:e,username:b.updates.filesystemCredentials.ftp.username,password:b.updates.filesystemCredentials.ftp.password,hostname:b.updates.filesystemCredentials.ftp.hostname,connection_type:b.updates.filesystemCredentials.ftp.connectionType,public_key:b.updates.filesystemCredentials.ssh.publicKey,private_key:b.updates.filesystemCredentials.ssh.privateKey};b.ajax.post("update-plugin",g).done(b.updates.updateSuccess).fail(b.updates.updateError)},b.updates.updateSuccess=function(d){var e;if("plugins"===c||"plugins-network"===c){var f=a('[data-slug="'+d.slug+'"]').first();e=f.next().find(".update-message"),f.addClass("updated").removeClass("update");var g=f.find(".plugin-version-author-uri").html().replace(d.oldVersion,d.newVersion);f.find(".plugin-version-author-uri").html(g)}else"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now"),e.addClass("button-disabled"));e.removeClass("updating-message").addClass("updated-message"),e.text(b.updates.l10n.updated),b.a11y.speak(b.updates.l10n.updatedMsg),b.updates.decrementCount("plugin"),b.updates.updateDoneSuccessfully=!0,b.updates.updateLock=!1,b.updates.queueChecker()},b.updates.updateError=function(d){var e;return b.updates.updateDoneSuccessfully=!1,d.errorCode&&"unable_to_connect_to_filesystem"==d.errorCode?void b.updates.credentialError(d,"update-plugin"):("plugins"===c||"plugins-network"===c?e=a('[data-slug="'+d.slug+'"]').next().find(".update-message"):"plugin-install"===c&&(e=a(".plugin-card-"+d.slug).find(".update-now")),e.removeClass("updating-message"),e.text(b.updates.l10n.updateFailed),void b.a11y.speak(b.updates.l10n.updateFailed))},b.updates.showErrorInCredentialsForm=function(b){var c=a(".notification-dialog");c.find(".error").remove(),c.find("h3").after(''+b+"
")},b.updates.credentialError=function(a,c){b.updates.updateQueue.push({type:c,data:{plugin:a.plugin,slug:a.slug}}),b.updates.showErrorInCredentialsForm(a.error),b.updates.requestFilesystemCredentials()},b.updates.queueChecker=function(){if(!(b.updates.updateLock||b.updates.updateQueue.length<=0)){var a=b.updates.updateQueue.shift();switch(a.type){case"update-plugin":b.updates.updatePlugin(a.data.plugin,a.data.slug);break;default:window.console.log("Failed to exect queued update job."),window.console.log(a)}}},b.updates.requestFilesystemCredentials=function(){b.updates.updateDoneSuccessfully===!1&&(b.updates.updateLock=!0,a("body").addClass("modal-open"),a("#request-filesystem-credentials-dialog").show())},a(document).ready(function(){b.updates.shouldRequestFilesystemCredentials=a("#request-filesystem-credentials-dialog").length<=0?!1:!0,a("#request-filesystem-credentials-dialog form").on("submit",function(){return b.updates.filesystemCredentials.ftp.hostname=a("#hostname").val(),b.updates.filesystemCredentials.ftp.username=a("#username").val(),b.updates.filesystemCredentials.ftp.password=a("#password").val(),b.updates.filesystemCredentials.ftp.connectionType=a('input[name="connection_type"]:checked').val(),b.updates.filesystemCredentials.ssh.publicKey=a("#public_key").val(),b.updates.filesystemCredentials.ssh.privateKey=a("#private_key").val(),a("#request-filesystem-credentials-dialog").hide(),a("body").removeClass("modal-open"),b.updates.updateLock=!1,b.updates.queueChecker(),!1}),a(".plugin-update-tr .update-link").on("click",function(c){c.preventDefault(),b.updates.shouldRequestFilesystemCredentials&&!b.updates.updateLock&&b.updates.requestFilesystemCredentials();var d=a(c.target).parents(".plugin-update-tr");b.updates.updatePlugin(d.data("plugin"),d.data("slug"))}),a("#bulk-action-form").on("submit",function(c){var d,e,f;"update-selected"==a("#bulk-action-selector-top").val()&&(c.preventDefault(),a('input[name="checked[]"]:checked').each(function(c,g){d=a(g),e=d.val(),f=d.parents("tr").prop("id"),b.updates.updatePlugin(e,f),d.attr("checked",!1)}))}),a(".plugin-card .update-now").on("click",function(c){c.preventDefault();var d=a(c.target);b.updates.updatePlugin(d.data("plugin"),d.data("slug"))})}),a(window).on("message",function(c){var d,e=c.originalEvent,f=document.location,g=f.protocol+"//"+f.hostname;e.origin===g&&(d=a.parseJSON(e.data),"undefined"!=typeof d.action&&"decrementUpdateCount"===d.action&&b.updates.decrementCount(d.upgradeType))})}(jQuery,window.wp,window.pagenow,window.ajaxurl);
\ No newline at end of file
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 8eea70f18d..27bb3dedd2 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '4.2-beta2-31896';
+$wp_version = '4.2-beta2-31897';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.