| @@ -22,20 +22,25 @@ | ||
| 22 | 22 | $('input#patchstack-activate').on( 'click', function(e) { |
| 23 | 23 | e.preventDefault(); |
| 24 | 24 | var postData = { |
| 25 | 25 | action: 'patchstack_activate_license', |
| 26 | - clientid: $( '#patchstack_api_client_id' ).val(), | |
| 27 | - secretkey: $( '#patchstack_api_client_secret_key' ).val(), | |
| 26 | + key: $( '#patchstack_api_key' ).val(), | |
| 28 | 27 | PatchstackNonce: PatchstackVars.nonce |
| 29 | 28 | }; |
| 30 | 29 | |
| 31 | - if ( $.trim( postData.clientid ).length == 0 || $.trim( postData.secretkey ).length == 0) { | |
| 32 | - alert( 'Please enter the site id and secret key.' ); | |
| 30 | + if ( $.trim( postData.key ).length == 0 ) { | |
| 31 | + alert( 'Please enter the API key.' ); | |
| 33 | 32 | return false; |
| 34 | 33 | } |
| 35 | 34 | |
| 35 | + $( '.patchstack-resync' ).hide(); | |
| 36 | + $( '#patchstack-activate' ).hide(); | |
| 37 | + $( '.patchstack-loading' ).show(); | |
| 38 | + | |
| 36 | 39 | $.post( PatchstackVars.ajaxurl, postData, function( response ) { |
| 37 | 40 | if ( response.result == 'error' ) { |
| 41 | + $( '#patchstack-activate' ).show(); | |
| 42 | + $( '.patchstack-loading' ).hide(); | |
| 38 | 43 | if ( response.error_message ) { |
| 39 | 44 | alert( response.error_message ); |
| 40 | 45 | } else { |
| 41 | 46 | alert( PatchstackVars.error_message ); |
| @@ -40,17 +45,9 @@ | ||
| 40 | 45 | } else { |
| 41 | 46 | alert( PatchstackVars.error_message ); |
| 42 | 47 | } |
| 43 | 48 | } else { |
| 44 | - if (response.response && response.response.free === false) { | |
| 45 | - window.location.reload(); | |
| 46 | - } else { | |
| 47 | - $( '.patchstack-license-status' ).text( 'Active' ).css( { color: '#B2D675' } ); | |
| 48 | - $( '.patchstack-sub-type' ).text( 'Community (Free) '); | |
| 49 | - $( '.ps-b1, .ps-p1' ).hide(); | |
| 50 | - $( '.ps-b3' ).removeClass('patchstack-fullwidth'); | |
| 51 | - $( '.ps-b2, .ps-b4, .ps-p2' ).show(); | |
| 52 | - } | |
| 49 | + window.location = window.location.href + '&resync=1'; | |
| 53 | 50 | } |
| 54 | 51 | }); |
| 55 | 52 | }); |
| 56 | 53 | |