From 11a597026398f52af74ee7d29b3fb1c41142d1fa Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Sun, 31 Jul 2016 18:56:57 +0000 Subject: [PATCH] Upgrade/Install: Trigger additional JS events in shiny updates Events for updating exist, but they lack context. This adds args so that plugins can detec t what plugin/theme is being installed. Additionally, events for bulk actions, deleting and that and install is starting didn't exist, so this adds them. Fixes #37512. Props DavidAnderson, and ocean90, swissspidy for review. git-svn-id: https://develop.svn.wordpress.org/trunk@38175 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/updates.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/updates.js b/src/wp-admin/js/updates.js index b58a2267e0..33756ffd74 100644 --- a/src/wp-admin/js/updates.js +++ b/src/wp-admin/js/updates.js @@ -369,7 +369,7 @@ .attr( 'aria-label', message ) .text( wp.updates.l10n.updating ); - $document.trigger( 'wp-plugin-updating' ); + $document.trigger( 'wp-plugin-updating', args ); return wp.updates.ajax( 'update-plugin', args ); }; @@ -525,6 +525,8 @@ // Remove previous error messages, if any. $card.removeClass( 'plugin-card-install-failed' ).find( '.notice.notice-error' ).remove(); + $document.trigger( 'wp-plugin-installing', args ); + return wp.updates.ajax( 'install-plugin', args ); }; @@ -715,6 +717,8 @@ wp.a11y.speak( wp.updates.l10n.deleting, 'polite' ); + $document.trigger( 'wp-plugin-deleting', args ); + return wp.updates.ajax( 'delete-plugin', args ); }; @@ -905,7 +909,7 @@ wp.a11y.speak( wp.updates.l10n.updatingMsg, 'polite' ); $notice.text( wp.updates.l10n.updating ); - $document.trigger( 'wp-theme-updating' ); + $document.trigger( 'wp-theme-updating', args ); return wp.updates.ajax( 'update-theme', args ); }; @@ -1038,6 +1042,8 @@ // Remove previous error messages, if any. $( '.install-theme-info, [data-slug="' + args.slug + '"]' ).removeClass( 'theme-install-failed' ).find( '.notice.notice-error' ).remove(); + $document.trigger( 'wp-theme-installing', args ); + return wp.updates.ajax( 'install-theme', args ); }; @@ -1167,6 +1173,8 @@ // Remove previous error messages, if any. $( '.theme-info .update-message' ).remove(); + $document.trigger( 'wp-theme-deleting', args ); + return wp.updates.ajax( 'delete-theme', args ); }; @@ -1973,6 +1981,8 @@ // Un-check the bulk checkboxes. $bulkActionForm.find( '.manage-column [type="checkbox"]' ).prop( 'checked', false ); + $document.trigger( 'wp-' + type + '-bulk-' + bulkAction, itemsSelected ); + // Find all the checkboxes which have been checked. itemsSelected.each( function( index, element ) { var $checkbox = $( element ),