PluginProbe
Two Factor Authentication / 1.2.6
Two Factor Authentication v1.2.6
1.12.2 1.13.0 1.14.10 1.14.11 1.14.14 1.14.15 1.14.16 1.14.17 1.14.23 1.14.24 1.14.26 1.14.27 1.14.3 1.14.4 1.14.5 1.14.7 1.14.8 1.15.5 1.16.0 1.2.10 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 All 98 releases
← All changes | two-factor-login.php +71 -107 1.2.131.2.6 View file →
@@ -4,18 +4,19 @@
4 4 Plugin URI: https://www.simbahosting.co.uk/s3/product/two-factor-authentication/
5 5 Description: Secure your WordPress login forms with two factor authentication - including WooCommerce login forms
6 6 Author: David Nutbourne + David Anderson, original plugin by Oskar Hane
7 7 Author URI: https://www.simbahosting.co.uk
8 -Version: 1.2.13
8 +Version: 1.2.6
9 9 License: GPLv2 or later
10 10 */
11 11
12 +define('SIMBA_TFA_TEXT_DOMAIN', 'two-factor-authentication');
12 13 define('SIMBA_TFA_PLUGIN_DIR', dirname( __FILE__ ));
13 14 define('SIMBA_TFA_PLUGIN_URL', plugins_url('', __FILE__));
14 15
15 16 class Simba_Two_Factor_Authentication {
16 17
17 - public $version = '1.2.13';
18 + public $version = '1.2.6';
18 19 private $php_required = '5.3';
19 20
20 21 private $frontend;
21 22
@@ -25,10 +26,10 @@
25 26 add_action('all_admin_notices', array($this, 'admin_notice_insufficient_php'));
26 27 $abort = true;
27 28 }
28 29
29 - if (!function_exists('mcrypt_get_iv_size') && !function_exists('openssl_cipher_iv_length')) {
30 - add_action('all_admin_notices', array($this, 'admin_notice_missing_mcrypt_and_openssl'));
30 + if (!function_exists('mcrypt_get_iv_size')) {
31 + add_action('all_admin_notices', array($this, 'admin_notice_missing_mcrypt'));
31 32 $abort = true;
32 33 }
33 34
34 35 if (!empty($abort)) return;
@@ -42,13 +43,8 @@
42 43 add_action('woocommerce_before_customer_login_form', array($this, 'woocommerce_before_customer_login_form'));
43 44 // The login form on the checkout doesn't call the woocommerce_before_customer_login_form action
44 45 add_action('woocommerce_before_checkout_form', array($this, 'woocommerce_before_customer_login_form'));
45 46
46 - add_action('affwp_login_fields_before', array($this, 'affwp_login_fields_before'));
47 - if (!defined('TWO_FACTOR_DISABLE') || !TWO_FACTOR_DISABLE) {
48 - add_action('affwp_process_login_form', array($this, 'affwp_process_login_form'));
49 - }
50 -
51 47 if (is_admin()) {
52 48 //Save settings
53 49 add_action('admin_init', array($this, 'check_possible_reset'));
54 50
@@ -136,13 +132,13 @@
136 132 }
137 133 }
138 134
139 135 public function admin_notice_insufficient_php() {
140 - $this->show_admin_warning('<strong>'.__('Higher PHP version required', 'updraftplus').'</strong><br> '.sprintf(__('The Two Factor Authentication plugin requires PHP version %s or higher - your current version is only %s.', 'two-factor-authentication'), $this->php_required, PHP_VERSION), 'error');
136 + $this->show_admin_warning('<strong>'.__('Higher PHP version required', 'updraftplus').'</strong><br> '.sprintf(__('The Two Factor Authentication plugin requires PHP version %s or higher - your current version is only %s.', SIMBA_TFA_TEXT_DOMAIN), $this->php_required, PHP_VERSION), 'error');
141 137 }
142 138
143 - public function admin_notice_missing_mcrypt_and_openssl() {
144 - $this->show_admin_warning('<strong>'.__('PHP OpenSSL or mcrypt module required', 'updraftplus').'</strong><br> '.__('The Two Factor Authentication plugin requires either the PHP openssl (preferred) or mcrypt module to be installed. Please ask your web hosting company to install one of them.', 'two-factor-authentication'), 'error');
139 + public function admin_notice_missing_mcrypt() {
140 + $this->show_admin_warning('<strong>'.__('PHP Mcrypt module required', 'updraftplus').'</strong><br> '.__('The Two Factor Authentication plugin requires the PHP mcrypt module to be installed. Please ask your web hosting company to install it.', SIMBA_TFA_TEXT_DOMAIN), 'error');
145 141 }
146 142
147 143 public function show_admin_warning($message, $class = "updated") {
148 144 echo '<div class="tfamessage '.$class.'">'."<p>$message</p></div>";
@@ -208,26 +204,29 @@
208 204
209 205 // Here's where the login action happens. Called on the 'authenticate' action.
210 206 public function tfaVerifyCodeAndUser($user, $username, $password) {
211 207
208 + $tfa = $this->getTFA();
209 +
212 210 if (is_wp_error($user)) return $user;
213 211
214 - $tfa = $this->getTFA();
215 212 $params = $_POST;
216 213 $params['log'] = $username;
217 214 $params['caller'] = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['REQUEST_URI'];
218 215
219 216 $code_ok = $tfa->authUserFromLogin($params);
217 +
220 218 if (is_wp_error($code_ok)) return $code_ok;
221 219
222 - if (!$code_ok) return new WP_Error('authentication_failed', '<strong>'.__('Error:', 'two-factor-authentication').'</strong> '.__('The one-time password (TFA code) you entered was incorrect.', 'two-factor-authentication'));
220 + if (!$code_ok) return new WP_Error('authentication_failed', '<strong>'.__('Error:', SIMBA_TFA_TEXT_DOMAIN).'</strong> '.__('The one-time password (TFA code) you entered was incorrect.', SIMBA_TFA_TEXT_DOMAIN));
223 221
224 222 if ($user) return $user;
225 223
226 224 return wp_authenticate_username_password(null, $username, $password);
227 225 }
228 -
229 - public function tfaRegisterTwoFactorAuthSettings() {
226 +
227 + public function tfaRegisterTwoFactorAuthSettings()
228 + {
230 229 global $wp_roles;
231 230 if (!isset($wp_roles))
232 231 $wp_roles = new WP_Roles();
233 232
@@ -254,13 +253,13 @@
254 253
255 254 if ($tfa->isRequiredForUser($user_id)) {
256 255 $requireafter = absint($this->get_option('tfa_requireafter'));
257 256
258 - echo '<p class="tfa_required_warning" style="font-weight:bold; font-style:italics;">'.sprintf(__('N.B. This site is configured to forbid you to log in if you disable two-factor authentication after your account is %d days old', 'two-factor-authentication'), $requireafter).'</p>';
257 + echo '<p class="tfa_required_warning" style="font-weight:bold; font-style:italics;">'.sprintf(__('N.B. This site is configured to forbid you to log in if you disable two-factor authentication after your account is %d days old', SIMBA_TFA_TEXT_DOMAIN), $requireafter).'</p>';
259 258 }
260 259
261 - $tfa_enabled_label = ($long_label) ? __('Enable two-factor authentication', 'two-factor-authentication') : __('Enabled', 'two-factor-authentication');
262 - $tfa_disabled_label = ($long_label) ? __('Disable two-factor authentication', 'two-factor-authentication') : __('Disabled', 'two-factor-authentication');
260 + $tfa_enabled_label = ($long_label) ? __('Enable two-factor authentication', SIMBA_TFA_TEXT_DOMAIN) : __('Enabled', SIMBA_TFA_TEXT_DOMAIN);
261 + $tfa_disabled_label = ($long_label) ? __('Disable two-factor authentication', SIMBA_TFA_TEXT_DOMAIN) : __('Disabled', SIMBA_TFA_TEXT_DOMAIN);
263 262
264 263 print '<input type="radio" class="tfa_enable_radio" id="tfa_enable_tfa_true" name="tfa_enable_tfa" value="true" '.($setting == true ? 'checked="checked"' :'').'> <label class="tfa_enable_radio_label" for="tfa_enable_tfa_true">'.apply_filters('simbatfa_radiolabel_enabled', $tfa_enabled_label, $long_label).'</label> <br>';
265 264
266 265 print '<input type="radio" class="tfa_enable_radio" id="tfa_enable_tfa_false" name="tfa_enable_tfa" value="false" '.($setting == false ? 'checked="checked"' :'').'> <label class="tfa_enable_radio_label" for="tfa_enable_tfa_false">'.apply_filters('simbatfa_radiolabel_disabled', $tfa_disabled_label, $long_label).'</label> <br>';
@@ -270,9 +269,9 @@
270 269 public function tfaListAlgorithmRadios($user_id)
271 270 {
272 271 if(!$user_id) return;
273 272
274 - $types = array('totp' => __('TOTP (time based - most common algorithm; used by Google Authenticator)', 'two-factor-authentication'), 'hotp' => __('HOTP (event based)', 'two-factor-authentication'));
273 + $types = array('totp' => __('TOTP (time based - most common algorithm; used by Google Authenticator)', SIMBA_TFA_TEXT_DOMAIN), 'hotp' => __('HOTP (event based)', SIMBA_TFA_TEXT_DOMAIN));
275 274
276 275 $setting = get_user_meta($user_id, 'tfa_algorithm_type', true);
277 276 $setting = $setting === false || !$setting ? 'totp' : $setting;
278 277
@@ -294,9 +293,9 @@
294 293
295 294 if (is_multisite()) {
296 295 // Not a real WP role; needs separate handling
297 296 $id = '_super_admin';
298 - $name = __('Multisite Super Admin', 'two-factor-authentication');
297 + $name = __('Multisite Super Admin', SIMBA_TFA_TEXT_DOMAIN);
299 298 $setting = $this->get_option('tfa_'.$id);
300 299 $setting = $setting === false || $setting ? 1 : 0;
301 300
302 301 print '<input type="checkbox" id="tfa_'.$id.'" name="tfa_'.$id.'" value="1" '.($setting ? 'checked="checked"' :'').'> <label for="tfa_'.$id.'">'.htmlspecialchars($name)."</label><br>\n";
@@ -320,9 +319,9 @@
320 319 $tfa = $this->getTFA();
321 320 $setting = $this->get_option('tfa_default_hmac');
322 321 $setting = $setting === false || !$setting ? $tfa->default_hmac : $setting;
323 322
324 - $types = array('totp' => __('TOTP (time based - most common algorithm; used by Google Authenticator)', 'two-factor-authentication'), 'hotp' => __('HOTP (event based)', 'two-factor-authentication'));
323 + $types = array('totp' => __('TOTP (time based - most common algorithm; used by Google Authenticator)', SIMBA_TFA_TEXT_DOMAIN), 'hotp' => __('HOTP (event based)', SIMBA_TFA_TEXT_DOMAIN));
325 324
326 325 foreach($types as $id => $name)
327 326 print '<input type="radio" id="tfa_default_hmac_'.esc_attr($id).'" name="tfa_default_hmac" value="'.$id.'" '.($setting == $id ? 'checked="checked"' :'').'> '.'<label for="tfa_default_hmac_'.esc_attr($id).'">'."$name</label><br>\n";
328 327 }
@@ -333,10 +332,10 @@
333 332 $setting = $this->get_option('tfa_xmlrpc_on');
334 333 $setting = $setting === false || !$setting ? 0 : 1;
335 334
336 335 $types = array(
337 - '0' => __('Do not require 2FA over XMLRPC (best option if you must use XMLRPC and your client does not support 2FA)', 'two-factor-authentication'),
338 - '1' => __('Do require 2FA over XMLRPC (best option if you do not use XMLRPC or are unsure)', 'two-factor-authentication')
336 + '0' => __('Do not require 2FA over XMLRPC (best option if you must use XMLRPC and your client does not support 2FA)', SIMBA_TFA_TEXT_DOMAIN),
337 + '1' => __('Do require 2FA over XMLRPC (best option if you do not use XMLRPC or are unsure)', SIMBA_TFA_TEXT_DOMAIN)
339 338 );
340 339
341 340 foreach($types as $id => $name)
342 341 print '<input type="radio" name="tfa_xmlrpc_on" id="tfa_xmlrpc_on_'.$id.'" value="'.$id.'" '.($setting == $id ? 'checked="checked"' :'').'> <label for="tfa_xmlrpc_on_'.$id.'">'.$name."</label><br>\n";
@@ -357,13 +356,11 @@
357 356 public function admin_menu()
358 357 {
359 358 $tfa = $this->getTFA();
360 359
361 - $tfa->potentially_port_private_keys();
362 -
363 360 global $current_user;
364 361 if(!$tfa->isActivatedForUser($current_user->ID)) return;
365 - add_menu_page(__('Two Factor Authentication', 'two-factor-authentication'), __('Two Factor Auth', 'two-factor-authentication'), 'read', 'two-factor-auth-user', array($this, 'tfaShowUserSettingsPage'), SIMBA_TFA_PLUGIN_URL.'/img/tfa_admin_icon_16x16.png', 72);
362 + add_menu_page(__('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN), __('Two Factor Auth', SIMBA_TFA_TEXT_DOMAIN), 'read', 'two-factor-auth-user', array($this, 'tfaShowUserSettingsPage'), SIMBA_TFA_PLUGIN_URL.'/img/tfa_admin_icon_16x16.png', 72);
366 363 }
367 364
368 365 public function menu_entry_for_admin() {
369 366
@@ -374,10 +371,10 @@
374 371
375 372 add_action( 'admin_init', array($this, 'tfaRegisterTwoFactorAuthSettings' ));
376 373
377 374 add_options_page(
378 - __('Two Factor Authentication', 'two-factor-authentication'),
379 - __('Two Factor Authentication', 'two-factor-authentication'),
375 + __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN),
376 + __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN),
380 377 'manage_options',
381 378 'two-factor-auth',
382 379 array($this, 'tfaShowAdminSettingsPage')
383 380 );
@@ -385,18 +382,18 @@
385 382
386 383 public function addPluginSettingsLink($links)
387 384 {
388 385 if (!is_network_admin()) {
389 - $link = '<a href="options-general.php?page=two-factor-auth">'.__('Plugin settings', 'two-factor-authentication').'</a>';
386 + $link = '<a href="options-general.php?page=two-factor-auth">'.__('Plugin settings', SIMBA_TFA_TEXT_DOMAIN).'</a>';
390 387 array_unshift($links, $link);
391 388 } else {
392 389 switch_to_blog(1);
393 - $link = '<a href="'.admin_url('options-general.php').'?page=two-factor-auth">'.__('Plugin settings', 'two-factor-authentication').'</a>';
390 + $link = '<a href="'.admin_url('options-general.php').'?page=two-factor-auth">'.__('Plugin settings', SIMBA_TFA_TEXT_DOMAIN).'</a>';
394 391 restore_current_blog();
395 392 array_unshift($links, $link);
396 393 }
397 394
398 - $link2 = '<a href="admin.php?page=two-factor-auth-user">'.__('User settings', 'two-factor-authentication').'</a>';
395 + $link2 = '<a href="admin.php?page=two-factor-auth-user">'.__('User settings', SIMBA_TFA_TEXT_DOMAIN).'</a>';
399 396 array_unshift($links, $link2);
400 397
401 398 return $links;
402 399 }
@@ -436,9 +433,9 @@
436 433 $url = $url_base.add_query_arg($add_query_args);
437 434
438 435 $url = wp_nonce_url($url, 'simbatfa_reset_private_key', 'nonce');
439 436
440 - return '<a href="javascript:if(confirm(\''.__('Warning: if you reset this key you will have to update your apps with the new one. Are you sure you want this?', 'two-factor-authentication').'\')){ window.location = \''.esc_js($url).'\'; }">'.__('Reset private key', 'two-factor-authentication').'</a>';
437 + return '<a href="javascript:if(confirm(\''.__('Warning: if you reset this key you will have to update your apps with the new one. Are you sure you want this?', SIMBA_TFA_TEXT_DOMAIN).'\')){ window.location = \''.esc_js($url).'\'; }">'.__('Reset private key', SIMBA_TFA_TEXT_DOMAIN).'</a>';
441 438
442 439 }
443 440
444 441 public function footer() {
@@ -455,9 +452,9 @@
455 452 "text": $('.simbaotp_qr_container:first').data('qrcode'),
456 453 });
457 454 $('.simbaotp_refresh').click(function(e) {
458 455 e.preventDefault();
459 - $(".simba_current_otp").html('<em><?php echo esc_attr(__('Updating...', 'two-factor-authentication'));?></em>');
456 + $(".simba_current_otp").html('<em><?php echo esc_attr(__('Updating...', SIMBA_TFA_TEXT_DOMAIN));?></em>');
460 457 $.post('<?php echo esc_js($ajax_url);?>', {
461 458 action: "simbatfa_shared_ajax",
462 459 subaction: "refreshotp",
463 460 nonce: "<?php echo esc_js(wp_create_nonce("tfa_shared_nonce"));?>"
@@ -467,9 +464,9 @@
467 464 var resp = $.parseJSON(response);
468 465 got_code = resp.code;
469 466 } catch(err) {
470 467 <?php if (!isset($also_try)) { ?>
471 - alert("<?php echo esc_js(__('Response:', 'two-factor-authentication')); ?> "+response);
468 + alert("<?php echo esc_js(__('Response:', 'SIMBA_TFA_TEXT_DOMAIN')); ?> "+response);
472 469 <?php } ?>
473 470 console.log(response);
474 471 console.log(err);
475 472 }
@@ -489,9 +486,9 @@
489 486 console.log(response);
490 487 console.log("TFA: no code found");
491 488 }
492 489 } catch(err) {
493 - alert("<?php echo esc_js(__('Response:', 'two-factor-authentication')); ?> "+response);
490 + alert("<?php echo esc_js(__('Response:', 'SIMBA_TFA_TEXT_DOMAIN')); ?> "+response);
494 491 console.log(response);
495 492 console.log(err);
496 493 }
497 494 });
@@ -518,18 +515,18 @@
518 515
519 516 $tfa_priv_key_64 = get_user_meta($user_id, 'tfa_priv_key_64', true);
520 517 if(!$tfa_priv_key_64) $tfa_priv_key_64 = $tfa->addPrivateKey($user_id);
521 518
522 - $tfa_priv_key = trim($tfa->getPrivateKeyPlain($tfa_priv_key_64, $user_id), "\x00..\x1F");
519 + $tfa_priv_key = trim($tfa->getPrivateKeyPlain($tfa_priv_key_64, $user_id));
523 520
524 521 $tfa_priv_key_32 = Base32::encode($tfa_priv_key);
525 522
526 523 if ('full' == $type) {
527 524 ?>
528 - <strong><?php echo __('Private key (base 32 - used by Google Authenticator and Authy):', 'two-factor-authentication');?></strong>
525 + <strong><?php echo __('Private key (base 32 - used by Google Authenticator and Authy):', SIMBA_TFA_TEXT_DOMAIN);?></strong>
529 526 <?php echo htmlspecialchars($tfa_priv_key_32); ?><br>
530 527
531 - <strong><?php echo __('Private key:', 'two-factor-authentication');?></strong>
528 + <strong><?php echo __('Private key:', SIMBA_TFA_TEXT_DOMAIN);?></strong>
532 529 <?php echo htmlspecialchars($tfa_priv_key); ?><br>
533 530 <?php
534 531 } elseif ('plain' == $type) {
535 532 echo htmlspecialchars($tfa_priv_key);
@@ -576,9 +573,9 @@
576 573 $tfa_priv_key_64 = get_user_meta($user_id, 'tfa_priv_key_64', true);
577 574
578 575 if(!$tfa_priv_key_64) $tfa_priv_key_64 = $tfa->addPrivateKey($user_id);
579 576
580 - $tfa_priv_key = trim($tfa->getPrivateKeyPlain($tfa_priv_key_64, $user_id), "\x00..\x1F");
577 + $tfa_priv_key = trim($tfa->getPrivateKeyPlain($tfa_priv_key_64, $user_id));
581 578
582 579 $tfa_priv_key_32 = Base32::encode($tfa_priv_key);
583 580
584 581 $algorithm_type = $tfa->getUserAlgorithm($user_id);
@@ -584,16 +581,16 @@
584 581 $algorithm_type = $tfa->getUserAlgorithm($user_id);
585 582
586 583 if ($admin) {
587 584 if ($current_user->ID == $user_id) {
588 - echo '<h2>'.__('Current codes', 'two-factor-authentication').'</h2>';
585 + echo '<h2>'.__('Current codes', SIMBA_TFA_TEXT_DOMAIN).'</h2>';
589 586 } else {
590 587 $user = get_user_by('id', $user_id);
591 588 $user_descrip = htmlspecialchars($user->user_nicename.' - '.$user->user_email);
592 - echo '<h2>'.sprintf(__('Current codes (login: %s)', 'two-factor-authentication'), $user_descrip).'</h2>';
589 + echo '<h2>'.sprintf(__('Current codes (login: %s)', SIMBA_TFA_TEXT_DOMAIN), $user_descrip).'</h2>';
593 590 }
594 591 } else {
595 -// echo '<h2>'.__('Current one-time password', 'two-factor-authentication').' '.$this->reset_current_otp_link().'</h2>';
592 +// echo '<h2>'.__('Current one-time password', SIMBA_TFA_TEXT_DOMAIN).' '.$this->reset_current_otp_link().'</h2>';
596 593 }
597 594
598 595 ?>
599 596 <div class="postbox">
@@ -599,9 +596,9 @@
599 596 <div class="postbox">
600 597
601 598 <?php if ($admin) { ?>
602 599 <h3 style="padding: 10px 6px 0px; margin:4px 0 0; cursor: default;">
603 - <span style="cursor: default;"><?php echo __('Current one-time password', 'two-factor-authentication').' ';
600 + <span style="cursor: default;"><?php echo __('Current one-time password', SIMBA_TFA_TEXT_DOMAIN).' ';
604 601 if ($current_user->ID == $user_id) { echo $this->reset_current_otp_link(); } ?>
605 602 </span>
606 603 <div class="inside">
607 604 <p><strong style="font-size: 3em;"><?php echo $this->current_otp_code($tfa, $user_id); ?></strong></p>
@@ -611,9 +608,9 @@
611 608 ?>
612 609 <div class="inside">
613 610 <p class="simbatfa-frontend-current-otp" style="font-size: 1.5em; margin-top:6px;">
614 611 <strong>
615 - <?php echo __('Current one-time password', 'two-factor-authentication').' '.$this->reset_current_otp_link(); ?>
612 + <?php echo __('Current one-time password', SIMBA_TFA_TEXT_DOMAIN).' '.$this->reset_current_otp_link(); ?>
616 613 </strong> :
617 614
618 615 <span class="simba_current_otp"><?php print $tfa->generateOTP($user_id, $tfa_priv_key_64); ?></span>
619 616
@@ -623,20 +620,20 @@
623 620 <?php } ?>
624 621
625 622 <?php if ($admin) { ?>
626 623 <h3 style="padding-left: 10px; cursor: default;">
627 - <span style="cursor: default;"><?php _e('QR code', 'two-factor-authentication'); ?></span>
624 + <span style="cursor: default;"><?php _e('QR code', SIMBA_TFA_TEXT_DOMAIN); ?></span>
628 625 </h3>
629 626 <?php } else {
630 - echo '<h2>'.__('QR code', 'two-factor-authentication').'</h2>';
627 + echo '<h2>'.__('QR code', SIMBA_TFA_TEXT_DOMAIN).'</h2>';
631 628 } ?>
632 629 <div class="inside">
633 630 <p>
634 - <?php _e('For OTP apps that support scanning, scanning this code is the quickest way to set the app up (e.g. with Duo Mobile, Google Authenticator)', 'two-factor-authentication'); ?>.
631 + <?php _e('For OTP apps that support scanning, scanning this code is the quickest way to set the app up (e.g. with Duo Mobile, Google Authenticator)', SIMBA_TFA_TEXT_DOMAIN); ?>.
635 632
636 - <?php _e('You are currently using', 'two-factor-authentication'); ?> <?php print strtoupper($algorithm_type).', '.($algorithm_type == 'totp' ? __('a time based', 'two-factor-authentication') : __('an event based', 'two-factor-authentication')); ?> <?php _e('algorithm', 'two-factor-authentication'); ?>.
633 + <?php _e('You are currently using', SIMBA_TFA_TEXT_DOMAIN); ?> <?php print strtoupper($algorithm_type).', '.($algorithm_type == 'totp' ? __('a time based', SIMBA_TFA_TEXT_DOMAIN) : __('an event based', SIMBA_TFA_TEXT_DOMAIN)); ?> <?php _e('algorithm', SIMBA_TFA_TEXT_DOMAIN); ?>.
637 634 </p>
638 - <p title="<?php echo sprintf(__("Private key: %s (base 32: %s)", 'two-factor-authentication'), $tfa_priv_key, $tfa_priv_key_32);?>">
635 + <p title="<?php echo sprintf(__("Private key: %s (base 32: %s)", SIMBA_TFA_TEXT_DOMAIN), $tfa_priv_key, $tfa_priv_key_32);?>">
639 636 <?php $qr_url = $this->tfa_qr_code_url($algorithm_type, $url, $tfa_priv_key) ?>
640 637 <div class="simbaotp_qr_container" data-qrcode="<?php echo esc_attr($qr_url); ?>"></div>
641 638 </p>
642 639 </div>
@@ -642,9 +639,9 @@
642 639 </div>
643 640
644 641 <div class="inside">
645 642
646 - <h3 class="normal" style="cursor: default"><?php _e('Private key - always to be kept secret - type this into your app to set it up (instead of scanning the code)', 'two-factor-authentication'); ?></h3>
643 + <h3 class="normal" style="cursor: default"><?php _e('Private key - always to be kept secret - type this into your app to set it up (instead of scanning the code)', SIMBA_TFA_TEXT_DOMAIN); ?></h3>
647 644
648 645 <p>
649 646 <?php
650 647 $this->print_private_keys($admin, 'full', $user_id);
@@ -657,13 +654,13 @@
657 654 if ($admin || apply_filters('simba_tfa_emergency_codes_user_settings', false, $user_id) !== false) {
658 655 ?>
659 656 <div class="inside">
660 657
661 - <h3 class="normal" style="cursor: default"><?php _e('Emergency codes', 'two-factor-authentication'); ?></h3>
658 + <h3 class="normal" style="cursor: default"><?php _e('Emergency codes', SIMBA_TFA_TEXT_DOMAIN); ?></h3>
662 659
663 660 <p>
664 661 <?php
665 - $default_text = '<a href="https://www.simbahosting.co.uk/s3/product/two-factor-authentication/">'.__('One-time emergency codes are a feature of the Premium version of this plugin.', 'two-factor-authentication').'</a>';
662 + $default_text = '<a href="https://www.simbahosting.co.uk/s3/product/two-factor-authentication/">'.__('One-time emergency codes are a feature of the Premium version of this plugin.', SIMBA_TFA_TEXT_DOMAIN).'</a>';
666 663 echo apply_filters('simba_tfa_emergency_codes_user_settings', $default_text, $user_id);
667 664 ?>
668 665 </p>
669 666
@@ -675,9 +672,9 @@
675 672 <?php
676 673 }
677 674
678 675 public function reset_current_otp_link($admin = true) {
679 - return '<a href="#" class="simbaotp_refresh">'.__('(update)', 'two-factor-authentication').'</a>';
676 + return '<a href="#" class="simbaotp_refresh">'.__('(update)', SIMBA_TFA_TEXT_DOMAIN).'</a>';
680 677 }
681 678
682 679 public function advanced_settings_box($submit_button_callback = false) {
683 680 $tfa = $this->getTFA();
@@ -685,15 +682,15 @@
685 682 global $current_user;
686 683 $algorithm_type = $tfa->getUserAlgorithm($current_user->ID);
687 684
688 685 ?>
689 - <h2><?php _e('Advanced settings', 'two-factor-authentication'); ?></h2>
686 + <h2><?php _e('Advanced settings', SIMBA_TFA_TEXT_DOMAIN); ?></h2>
690 687
691 688 <div id="tfa_advanced_box" class="tfa_settings_form" style="margin-top: 20px;">
692 689
693 690 <?php if (false === $submit_button_callback) { ?><form method="post" action="<?php print esc_url(add_query_arg('settings-updated', 'true', $_SERVER['REQUEST_URI'])); ?>"><?php } ?>
694 691
695 - <?php _e('Choose which algorithm for One Time Passwords you want to use.', 'two-factor-authentication'); ?>
692 + <?php _e('Choose which algorithm for One Time Passwords you want to use.', SIMBA_TFA_TEXT_DOMAIN); ?>
696 693 <p>
697 694 <?php
698 695 $this->tfaListAlgorithmRadios($current_user->ID);
699 696 if($algorithm_type == 'hotp')
@@ -698,9 +695,9 @@
698 695 $this->tfaListAlgorithmRadios($current_user->ID);
699 696 if($algorithm_type == 'hotp')
700 697 {
701 698 $counter = $tfa->getUserCounter($current_user->ID);
702 - print '<br>'.__('Your counter on the server is currently on', 'two-factor-authentication').': '.$counter;
699 + print '<br>'.__('Your counter on the server is currently on', SIMBA_TFA_TEXT_DOMAIN).': '.$counter;
703 700 }
704 701 ?>
705 702
706 703 </p>
@@ -719,12 +716,12 @@
719 716
720 717 wp_enqueue_script( 'tfa-ajax-request', SIMBA_TFA_PLUGIN_URL . '/includes/tfa.js', array( 'jquery' ), $script_ver );
721 718 $localize = array(
722 719 'ajaxurl' => admin_url('admin-ajax.php'),
723 - 'click_to_enter_otp' => __("Click to enter One Time Password", 'two-factor-authentication'),
724 - 'enter_username_first' => __('You have to enter a username first.', 'two-factor-authentication'),
725 - 'otp' => __("One Time Password (i.e. 2FA)", 'two-factor-authentication'),
726 - 'otp_login_help' => __('(check your OTP app to get this password)', 'two-factor-authentication'),
720 + 'click_to_enter_otp' => __("Click to enter One Time Password", SIMBA_TFA_TEXT_DOMAIN),
721 + 'enter_username_first' => __('You have to enter a username first.', SIMBA_TFA_TEXT_DOMAIN),
722 + 'otp' => __("One Time Password (i.e. 2FA)", SIMBA_TFA_TEXT_DOMAIN),
723 + 'otp_login_help' => __('(check your OTP app to get this password)', SIMBA_TFA_TEXT_DOMAIN),
727 724 'nonce' => wp_create_nonce("simba_tfa_loginform_nonce")
728 725 );
729 726 // Spinner exists since WC 3.8. Use the proper functions to avoid SSL warnings.
730 727 if (file_exists(ABSPATH.'wp-admin/images/spinner.gif')) {
@@ -743,15 +740,15 @@
743 740 return;
744 741
745 742 ?>
746 743 <div class="error">
747 - <h3><?php _e('Two Factor Authentication re-sync needed', 'two-factor-authentication');?></h3>
744 + <h3><?php _e('Two Factor Authentication re-sync needed', SIMBA_TFA_TEXT_DOMAIN);?></h3>
748 745 <p>
749 - <?php _e('You need to resync your device for Two Factor Authentication since the OTP you last used is many steps ahead of the server.', 'two-factor-authentication'); ?>
746 + <?php _e('You need to resync your device for Two Factor Authentication since the OTP you last used is many steps ahead of the server.', SIMBA_TFA_TEXT_DOMAIN); ?>
750 747 <br>
751 - <?php _e('Please re-sync or you might not be able to log in if you generate more OTPs without logging in.', 'two-factor-authentication');?>
748 + <?php _e('Please re-sync or you might not be able to log in if you generate more OTPs without logging in.', SIMBA_TFA_TEXT_DOMAIN);?>
752 749 <br><br>
753 - <a href="admin.php?page=two-factor-auth-user&warning_button_clicked=1" class="button"><?php _e('Click here and re-scan the QR-Code', 'two-factor-authentication');?></a>
750 + <a href="admin.php?page=two-factor-auth-user&warning_button_clicked=1" class="button"><?php _e('Click here and re-scan the QR-Code', SIMBA_TFA_TEXT_DOMAIN);?></a>
754 751 </p>
755 752 </div>
756 753
757 754 <?php
@@ -785,12 +782,12 @@
785 782
786 783 public function settings_intro_notices() {
787 784 ?>
788 785 <p class="simba_tfa_personal_settings_notice simba_tfa_intro_notice">
789 - <?php echo __('These are your personal settings.', 'two-factor-authentication').' '.__('Nothing you change here will have any effect on other users.', 'two-factor-authentication'); ?>
786 + <?php echo __('These are your personal settings.', SIMBA_TFA_TEXT_DOMAIN).' '.__('Nothing you change here will have any effect on other users.', SIMBA_TFA_TEXT_DOMAIN); ?>
790 787 </p>
791 788 <p class="simba_tfa_verify_tfa_notice simba_tfa_intro_notice"><strong>
792 - <?php _e('If you activate two-factor authentication, then verify that your two-factor application is showing the same One Time Password as shown on this page before you log out.', 'two-factor-authentication'); ?></strong> <?php if (current_user_can('manage_options')) { ?><a href="https://wordpress.org/plugins/two-factor-authentication/faq/"><?php _e('You should also bookmark the FAQs, which explain how to de-activate the plugin even if you cannot log in.', 'two-factor-authentication');?></a><?php } ?>
789 + <?php _e('If you activate two-factor authentication, then verify that your two-factor application is showing the same One Time Password as shown on this page before you log out.', SIMBA_TFA_TEXT_DOMAIN); ?></strong> <?php if (current_user_can('manage_options')) { ?><a href="https://wordpress.org/plugins/two-factor-authentication/faq/"><?php _e('You should also bookmark the FAQs, which explain how to de-activate the plugin even if you cannot log in.', SIMBA_TFA_TEXT_DOMAIN);?></a><?php } ?>
793 790 </p>
794 791 <?php
795 792 }
796 793
@@ -795,9 +792,9 @@
795 792 }
796 793
797 794 public function plugins_loaded() {
798 795 load_plugin_textdomain(
799 - 'two-factor-authentication',
796 + SIMBA_TFA_TEXT_DOMAIN,
800 797 false,
801 798 dirname( plugin_basename( __FILE__ ) ) . '/languages/'
802 799 );
803 800 }
@@ -811,47 +808,19 @@
811 808 public function shortcode_when_not_logged_in() {
812 809 return '';
813 810 }
814 811
815 - // Affiliate-WP login form
816 - public function affwp_login_fields_before() {
817 - $this->before_login_form_generic();
818 - }
819 -
820 - public function affwp_process_login_form() {
821 - if (!function_exists('affiliate_wp')) return;
822 - $affiliate_wp = affiliate_wp();
823 - $login = $affiliate_wp->login;
824 -
825 - $tfa = $this->getTFA();
826 - $params = array(
827 - 'log' => (string)$_POST['affwp_user_login'],
828 - 'caller'=> $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['REQUEST_URI'],
829 - 'two_factor_code' => (string)$_POST['two_factor_code']
830 - );
831 - $code_ok = $tfa->authUserFromLogin($params);
832 - if (is_wp_error($code_ok)) {
833 - $login->add_error($code_ok->get_error_code, $code_ok->get_error_message());
834 - } elseif (!$code_ok) {
835 - $login->add_error('authentication_failed', __('Error:', 'two-factor-authentication').' '.__('The one-time password (TFA code) you entered was incorrect.', 'two-factor-authentication'));
836 - }
837 -
838 - }
839 -
840 - // Shared by some 3rd-party login forms
841 - // For historical reasons there are references to WooCommerce in this code - left for the sake of not fixing what was not broken
842 - private function before_login_form_generic() {
843 -
812 + // WooCommerce login form
813 + public function woocommerce_before_customer_login_form() {
844 814 $script_ver = (defined('WP_DEBUG') && WP_DEBUG) ? time() : $this->version;
845 815 wp_enqueue_script( 'tfa-wc-ajax-request', SIMBA_TFA_PLUGIN_URL.'/includes/wooextend.js', array('jquery'), $script_ver);
846 -
847 816 $localize = array(
848 817 'ajaxurl' => admin_url('admin-ajax.php'),
849 - 'click_to_enter_otp' => __("Enter One Time Password (if you have one)", 'two-factor-authentication'),
850 - 'enter_username_first' => __('You have to enter a username first.', 'two-factor-authentication'),
851 - 'otp' => __("One Time Password", 'two-factor-authentication'),
818 + 'click_to_enter_otp' => __("Enter One Time Password (if you have one)", SIMBA_TFA_TEXT_DOMAIN),
819 + 'enter_username_first' => __('You have to enter a username first.', SIMBA_TFA_TEXT_DOMAIN),
820 + 'otp' => __("One Time Password", SIMBA_TFA_TEXT_DOMAIN),
852 821 'nonce' => wp_create_nonce("simba_tfa_loginform_nonce"),
853 - 'otp_login_help' => __('(check your OTP app to get this password)', 'two-factor-authentication'),
822 + 'otp_login_help' => __('(check your OTP app to get this password)', SIMBA_TFA_TEXT_DOMAIN),
854 823 );
855 824 // Spinner exists since WC 3.8. Use the proper functions to avoid SSL warnings.
856 825 if (file_exists(ABSPATH.'wp-admin/images/spinner.gif')) {
857 826 $localize['spinnerimg'] = admin_url('images/spinner.gif');
@@ -859,13 +828,8 @@
859 828 $localize['spinnerimg'] = includes_url('images/spinner.gif');
860 829 }
861 830
862 831 wp_localize_script( 'tfa-wc-ajax-request', 'simbatfa_wc_settings', $localize);
863 - }
864 -
865 - // WooCommerce login form
866 - public function woocommerce_before_customer_login_form() {
867 - $this->before_login_form_generic();
868 832 }
869 833
870 834 }
871 835