| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template is used to display 2FA TOTP field and reset button. |
| 4 |
* |
| 5 |
* @package WP_Defender |
| 6 |
*/ |
| 7 |
|
| 8 |
?> |
| 9 |
<p class="error"></p> |
| 10 |
<div id="defender-totp"></div> |
| 11 |
<script type="text/javascript"> |
| 12 |
jQuery(function ($) { |
| 13 |
// Toggle. |
| 14 |
$('body').on('click', '#field-totp', function () { |
| 15 |
var el = $('.reset-totp-keys'); |
| 16 |
if (this.checked) { |
| 17 |
el.prop('disabled', false); |
| 18 |
} else { |
| 19 |
el.prop('disabled', true); |
| 20 |
} |
| 21 |
}); |
| 22 |
// Reset settings. |
| 23 |
$('body').on('click', '.reset-totp-keys', function () { |
| 24 |
var el = $(this); |
| 25 |
$.ajax({ |
| 26 |
type: 'POST', |
| 27 |
url: '<?php echo $url; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>', |
| 28 |
data: {}, |
| 29 |
dataType: 'JSON', |
| 30 |
beforeSend: function () { |
| 31 |
el.attr('disabled', 'disabled'); |
| 32 |
}, |
| 33 |
success: function (data) { |
| 34 |
if (data.success == true) { |
| 35 |
$('#field-totp').prop('checked', false); |
| 36 |
location.reload(); |
| 37 |
} else { |
| 38 |
el.removeAttr('disabled'); |
| 39 |
el.closest('.well').find('.error').text(data.data.message).show(); |
| 40 |
} |
| 41 |
} |
| 42 |
}); |
| 43 |
}) |
| 44 |
}) |
| 45 |
</script> |
| 46 |
|