-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.js
More file actions
68 lines (60 loc) · 2.09 KB
/
Copy pathadmin.js
File metadata and controls
68 lines (60 loc) · 2.09 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
65
66
67
68
jQuery(document).ready(function($) {
'use strict';
// Gerar API Key
$('#carz-generate-api-key').on('click', function(e) {
e.preventDefault();
var $button = $(this);
var originalText = $button.text();
$button.text(carzApiAdmin.strings.generating).prop('disabled', true);
$.ajax({
url: carzApiAdmin.ajax_url,
type: 'POST',
data: {
action: 'carz_generate_api_key',
nonce: carzApiAdmin.nonce
},
success: function(response) {
if (response.success) {
$('#carz_api_key').val(response.data.api_key);
alert(carzApiAdmin.strings.key_generated);
} else {
alert(response.data.message || carzApiAdmin.strings.error);
}
},
error: function() {
alert(carzApiAdmin.strings.error);
},
complete: function() {
$button.text(originalText).prop('disabled', false);
}
});
});
// Flush rewrite rules
$('#carz-flush-rewrite').on('click', function(e) {
e.preventDefault();
var $button = $(this);
var originalText = $button.text();
$button.text(carzApiAdmin.strings.flushing).prop('disabled', true);
$.ajax({
url: carzApiAdmin.ajax_url,
type: 'POST',
data: {
action: 'carz_test_endpoint',
nonce: carzApiAdmin.nonce
},
success: function(response) {
if (response.success) {
alert(carzApiAdmin.strings.flushed_success);
} else {
alert(response.data.message || carzApiAdmin.strings.error);
}
},
error: function() {
alert(carzApiAdmin.strings.error);
},
complete: function() {
$button.text(originalText).prop('disabled', false);
}
});
});
});