upsell.js
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
jQuery(document).ready(function($)
{
$('.emr-installer').on('click', function(e){
e.preventDefault();
var button = $(this);
var plugin = button.data('plugin');
var nonce = $('#upsell-nonce').val();
button.text(emr_upsell.installing);
var enr_eg_opts = {
url: emr_upsell.ajax,
type: 'post',
async: true,
cache: false,
dataType: 'json',
data: {
action: 'emr_plugin_install',
nonce: nonce,
plugin: plugin //'https://downloads.wordpress.org/plugin/envira-gallery-lite.zip',
},
success: function(response) {
$(button).addClass('hidden');
$('.emr-activate[data-plugin="' + plugin + '"]').removeClass('hidden');
},
error: function(xhr, textStatus, e) {
},
};
$.ajax(enr_eg_opts);
});
$('.emr-activate').on('click', function(e){
e.preventDefault();
var button = $(this);
var plugin = button.data('plugin');
var nonce = $('#upsell-nonce-activate').val();
var enr_eg_opts = {
url: emr_upsell.ajax,
type: 'post',
async: true,
cache: false,
dataType: 'json',
data: {
action: 'emr_plugin_activate',
nonce: nonce,
plugin: plugin,
},
success: function(response) {
$(button).addClass('hidden')
$('.emr-activate-done[data-plugin="' + plugin + '"]').removeClass('hidden');
},
error: function(xhr, textStatus, e) {
},
};
$.ajax(enr_eg_opts);
});
});