PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / view / two-fa / providers / backup-codes.php

backup-codes.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/view/two-fa/providers/backup-codes.php

88 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <p id="wpdef-2fa-backup-codes">
2 <button type="button" class="button button-wpdef-2fa-backup-codes-generate button-secondary hide-if-no-js"
3 <?php echo esc_attr( $attr ); ?>>
4 <?php echo $button_text; ?>
5 </button>
6 <span class="wpdef-2fa-backup-codes-count <?php echo esc_attr( $class ); ?>">
7 <?php echo esc_html( $number_of_codes ); ?>
8 <input type="hidden" name="wpdef_need_notice" id="wpdef-need-notice" value="<?php echo esc_attr( $show_notice ); ?>"/>
9 </span>
10 </p>
11 <?php if ( 'yes' === $show_notice ) { ?>
12 <div id="backup-codes-notification" class="def-notification <?php echo esc_attr( $class ); ?>">
13 <span class="dashicons dashicons-warning"></span>
14 <?php _e( 'Generate new backup codes by clicking the button above.', 'wpdef' ); ?>
15 </div>
16 <?php } ?>
17 <div class="wpdef-2fa-backup-codes-wrapper" style="display: none">
18 <p class="description"><?php esc_html_e( 'Ensure your backup codes are saved in a safe and accessible place. You won’t be able to view these codes again.', 'wpdef' ); ?></p>
19 <p class="download-button">
20 <a class="button button-primary button-wpdef-2fa-backup-codes-download button-secondary hide-if-no-js" href="javascript:void(0);" id="wpdef-2fa-backup-codes-download-link" download="defender-backup-codes.txt"><?php esc_html_e( 'Download Codes', 'wpdef' ); ?></a>
21 <p>
22 <div class="wpdef-2fa-backup-codes-unused-codes"></div>
23 </div>
24 <script type="text/javascript">
25 ( function( $ ) {
26 // Toggle.
27 $('body').on('click', '#field-backup-codes', function(){
28 var el = $('.button-wpdef-2fa-backup-codes-generate');
29 var textWithCodes = $('.wpdef-2fa-backup-codes-count');
30 // When 0 codes.
31 var needNotice = $('#wpdef-need-notice').val();
32 if (this.checked) {
33 el.prop('disabled', false);
34 textWithCodes.show();
35 if (needNotice === 'yes') {
36 $('.def-notification').show();
37 }
38 } else {
39 el.prop('disabled', true);
40 textWithCodes.hide();
41 if (needNotice === 'yes') {
42 $('.def-notification').hide();
43 }
44 }
45 });
46 //Generate backup codes.
47 $( '.button-wpdef-2fa-backup-codes-generate' ).on( 'click', function() {
48 var el = $(this);
49 $.ajax( {
50 method: 'POST',
51 url: '<?php echo $url; ?>',
52 data: {},
53 dataType: 'JSON',
54 success: function( response ) {
55 if (response.success == true) {
56 // Remove old notification.
57 if ( $('#backup-codes-notification').length > 0 ) {
58 $('#backup-codes-notification').hide();
59 }
60 // Change the button text.
61 el.text(response.data.button_text);
62 // Change description.
63 $('.backup-codes-provider-text').text(response.data.description)
64 var $codesList = $( '.wpdef-2fa-backup-codes-unused-codes' );
65 $( '.wpdef-2fa-backup-codes-wrapper' ).show();
66 $codesList.html( '' );
67 // Append the codes.
68 for ( i = 0; i < response.data.codes.length; i++ ) {
69 $codesList.append( '<p>' + response.data.codes[ i ] + '</p>' );
70 }
71 // Update counter.
72 $( '.wpdef-2fa-backup-codes-count' ).html( response.data.count );
73 // Build the download link.
74 var txt_data = 'data:application/text;charset=utf-8,';
75 txt_data += response.data.title + '\n';
76 for ( i = 0; i < response.data.codes.length; i++ ) {
77 txt_data += response.data.codes[ i ] + '\n';
78 }
79 $( '#wpdef-2fa-backup-codes-download-link' ).attr( 'href', encodeURI( txt_data ) );
80 } else {
81 // Error case.
82 }
83 }
84 } );
85 } );
86 } )( jQuery );
87 </script>
88