revoke-grace-period.php
1.88 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
<?php
if (!defined('WORDFENCE_LS_VERSION')) { exit; }
$errorMessage = __('Unable to Revoke Grace Period', 'wordfence-2fa');
?>
<div class="wfls-add-top wfls-add-bottom wfls-grace-period-container">
<div class="wfls-grace-period-button-container">
<button class="wfls-btn wfls-btn-default" id="wfls-revoke-grace-period">
<?php esc_html_e('Revoke Grace Period', 'wordfence-2fa') ?>
</button>
</div>
</div>
<div>
<p id="wfls-revoke-grace-period-failed" style="display: none"><strong><?php echo esc_html($errorMessage) ?></strong></p>
</div>
<script type="application/javascript">
(function($) {
$(function() {
var failureMessage = $('#wfls-revoke-grace-period-failed');
var button = $('#wfls-revoke-grace-period');
function revoke2faGracePeriod(userId, success, failure) {
var ajaxContext = (typeof WFLS === 'undefined' ? GWFLS : WFLS);
ajaxContext.ajax(
'wordfence_ls_revoke_2fa_grace_period',
{
user_id: userId
},
success,
failure
);
}
function handleError() {
if (typeof WFLS === 'object') {
WFLS.panelModal(
(WFLS.screenSize(500) ? '300px' : '400px'),
<?php echo json_encode($errorMessage) ?>,
<?php echo json_encode(__('An unexpected error occurred while attempting to revoke the grace period.', 'wordfence-2fa')) ?>
);
}
else {
failureMessage.show();
}
button.prop('disabled', false);
}
button.on('click', function(e) {
e.preventDefault();
e.stopPropagation();
button.prop('disabled', true);
failureMessage.hide();
revoke2faGracePeriod(
<?php echo json_encode($user->ID, true) ?>,
function(data) {
if ('error' in data) {
handleError();
return;
}
if (typeof WFLS === 'undefined')
window.location.href = '#wfls-user-settings';
window.location.reload();
},
handleError
);
});
});
})(jQuery);
</script>