@@ -107,7 +107,7 @@ function pluginUploadSuccess( fileObj, serverData ) {
107107 ) ;
108108 }
109109 action_selector . append (
110- `<li><button class="button activate-button cancel-overwrite" data-file="${ fileObj . id } " data-attachment="${ data . attachment_id } "> ${ plugin_upload_intl . cancel } </button></li>`
110+ `<li><button class="button activate-button cancel-overwrite" data-file="${ fileObj . id } " data-attachment="${ data . attachment_id } "> ${ plugin_upload_intl . cancel } </button></li>`
111111 ) ;
112112 action_selector . append (
113113 `<li><a href="#TB_inline?&inlineId=plugin-modal-window-${ fileObj . id } &width=700" class="thickbox" data-title="${ data . plugin . Name } ${ data . plugin . Version } ">${ plugin_upload_intl . more_details } </a></li>`
@@ -132,7 +132,7 @@ function pluginUploadSuccess( fileObj, serverData ) {
132132 } ) ;
133133 } else {
134134 action_selector . append (
135- `<li><button class="button activate-button activate-plugin button-primary" data-name="${ data . plugin . Name } " data-path="${ data . path } "> ${ plugin_upload_intl . activate } </button></li>`
135+ `<li><button class="button activate-button activate-plugin button-primary" data-name="${ data . plugin . Name } " data-path="${ data . path } "> ${ plugin_upload_intl . activate } </button></li>`
136136 ) ;
137137
138138 jQuery ( '.button.activate-plugin' )
@@ -141,7 +141,7 @@ function pluginUploadSuccess( fileObj, serverData ) {
141141 const button = jQuery ( this ) ;
142142 const path = button . data ( 'path' ) ;
143143 const name = button . data ( 'name' ) ;
144- activatePlugin ( path , name , button ) ;
144+ activatePlugin ( path , name , button ) ;
145145 } ) ;
146146 }
147147}
@@ -176,47 +176,50 @@ function overwritePlugin( attachment_id, button ) {
176176 const formData = new FormData ( ) ;
177177 formData . append ( '_wpnonce' , upload_plugin_nonce ) ;
178178 formData . append ( 'action' , 'upload-plugin' ) ;
179- button . prop ( 'disabled' , true ) ;
179+ button . prop ( 'disabled' , true ) ;
180180 button . text ( plugin_upload_intl . processing + '...' ) ;
181-
181+ const cancel_overwrite_button = button . parent ( ) . parent ( ) . find ( '.cancel-overwrite' ) ;
182+ cancel_overwrite_button . prop ( 'disabled' , true ) ;
182183 jQuery . ajax ( {
183184 type : 'POST' ,
184185 url : ajaxurl + '?package=' + attachment_id + '&overwrite=update-plugin' ,
185186 data : formData ,
186187 processData : false , // Important: tell jQuery not to process the data.
187188 contentType : false , // Important: tell jQuery not to set contentType.
188189
189- success : function ( ) {
190+ success : function ( ) {
190191 button . text ( plugin_upload_intl . updated ) ;
191192 } ,
192- error : function ( ) {
193+ error : function ( ) {
193194 button . prop ( 'disabled' , false ) ;
195+ cancel_overwrite_button . prop ( 'disabled' , false ) ;
194196 button . text ( plugin_upload_intl . activation_failed ) ;
195197 } ,
196198 } ) ;
197199}
198200
199- function cancelOverwritePlugin ( file_id , attachment_id , button ) {
200- const formData = new FormData ( ) ;
201+ function cancelOverwritePlugin ( file_id , attachment_id , button ) {
202+ const formData = new FormData ( ) ;
201203 formData . append ( '_wpnonce' , cancel_overwrite_nonce ) ;
202204 formData . append ( 'action' , 'cancel-plugin-overwrite' ) ;
203205 button . prop ( 'disabled' , true ) ;
204206 button . text ( plugin_upload_intl . processing + '...' ) ;
205-
207+ const overwrite_button = button . parent ( ) . parent ( ) . find ( '.overwrite-plugin' ) ;
208+ overwrite_button . prop ( 'disabled' , true ) ;
206209 jQuery . ajax ( {
207210 type : 'POST' ,
208211 url : ajaxurl + '?package=' + attachment_id ,
209212 data : formData ,
210213 processData : false , // Important: tell jQuery not to process the data.
211214 contentType : false , // Important: tell jQuery not to set contentType.
212215
213- success : function ( ) {
216+ success : function ( ) {
214217 // Remove element from the dom.
215- jQuery ( '#plugin-item-' + file_id ) . remove ( ) ;
216-
218+ jQuery ( '#plugin-item-' + file_id ) . remove ( ) ;
217219 } ,
218- error : function ( ) {
220+ error : function ( ) {
219221 button . prop ( 'disabled' , false ) ;
222+ overwrite_button . prop ( 'disabled' , false ) ;
220223 button . text ( plugin_upload_intl . cancel_failed ) ;
221224 } ,
222225 } ) ;
@@ -237,10 +240,10 @@ function activatePlugin( path, name, button ) {
237240 processData : false , // Important: tell jQuery not to process the data
238241 contentType : false , // Important: tell jQuery not to set contentType
239242
240- success : function ( ) {
243+ success : function ( ) {
241244 button . text ( plugin_upload_intl . activated ) ;
242245 } ,
243- error : function ( ) {
246+ error : function ( ) {
244247 button . prop ( 'disabled' , false ) ;
245248 button . text ( plugin_upload_intl . failed ) ;
246249 } ,
0 commit comments