| 1 |
/** |
| 2 |
* WebFactory Licensing Manager |
| 3 |
* (c) WebFactory Ltd |
| 4 |
* www.webfactoryltd.com |
| 5 |
*/ |
| 6 |
|
| 7 |
|
| 8 |
function wf_licensing_verify_licence_ajax(prefix, license_key, button) { |
| 9 |
data = window['wf_licensing_' + prefix]; |
| 10 |
if (!data) { |
| 11 |
alert('Licensing data is missing. Please reload the page and try again.'); |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
jQuery(button).addClass('loading'); |
| 16 |
|
| 17 |
jQuery |
| 18 |
.post( |
| 19 |
ajaxurl, |
| 20 |
{ |
| 21 |
action: 'wf_licensing_' + prefix + '_validate', |
| 22 |
license_key: license_key, |
| 23 |
_ajax_nonce: data.nonce, |
| 24 |
_rand: Math.floor(Math.random() * 9999) + 1 |
| 25 |
}, |
| 26 |
function (response) { |
| 27 |
if (data.debug) { |
| 28 |
console.log('Validate license, first try: ', response); |
| 29 |
} |
| 30 |
if (response.success) { |
| 31 |
location.reload(); |
| 32 |
} else { |
| 33 |
alert('Unable to contact licensing server. Please try again in a few moments or contact support.'); |
| 34 |
} |
| 35 |
} |
| 36 |
) |
| 37 |
.fail(function () { |
| 38 |
alert('Undocumented error. Please reload the page and try again.'); |
| 39 |
}) |
| 40 |
.always(function () { |
| 41 |
jQuery(button).removeClass('loading'); |
| 42 |
jQuery(window).trigger('wf_licensing:ajax_always'); |
| 43 |
}); |
| 44 |
} // wf_licensing_verify_licence_ajax |
| 45 |
|
| 46 |
|
| 47 |
function wf_licensing_deactivate_licence_ajax(prefix, license_key, button) { |
| 48 |
data = window['wf_licensing_' + prefix]; |
| 49 |
if (!data) { |
| 50 |
alert('Licensing data is missing. Please reload the page and try again.'); |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
jQuery(button).addClass('loading'); |
| 55 |
|
| 56 |
jQuery |
| 57 |
.post( |
| 58 |
ajaxurl, |
| 59 |
{ |
| 60 |
action: 'wf_licensing_' + prefix + '_deactivate', |
| 61 |
license_key: license_key, |
| 62 |
_ajax_nonce: data.nonce, |
| 63 |
_rand: Math.floor(Math.random() * 9999) + 1 |
| 64 |
}, |
| 65 |
function (response) { |
| 66 |
if (data.debug) { |
| 67 |
console.log('Deactivate license, first try: ', response); |
| 68 |
} |
| 69 |
if (response.success) { |
| 70 |
location.reload(); |
| 71 |
} else { |
| 72 |
alert('Unable to contact licensing server. Please try again in a few moments or contact support.'); |
| 73 |
} |
| 74 |
} |
| 75 |
) |
| 76 |
.fail(function () { |
| 77 |
alert('Undocumented error. Please reload the page and try again.'); |
| 78 |
}) |
| 79 |
.always(function () { |
| 80 |
jQuery(button).removeClass('loading'); |
| 81 |
jQuery(window).trigger('wf_licensing:ajax_always'); |
| 82 |
}); |
| 83 |
} // wf_licensing_deactivate_licence_ajax |
| 84 |
|