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 -109 1.2.141.2.6 View file →
@@ -4,20 +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.14
9 -Text Domain: two-factor-authentication
10 -Domain Path: /languages
8 +Version: 1.2.6
11 9 License: GPLv2 or later
12 10 */
13 11
12 +define('SIMBA_TFA_TEXT_DOMAIN', 'two-factor-authentication');
14 13 define('SIMBA_TFA_PLUGIN_DIR', dirname( __FILE__ ));
15 14 define('SIMBA_TFA_PLUGIN_URL', plugins_url('', __FILE__));
16 15
17 16 class Simba_Two_Factor_Authentication {
18 17
19 - public $version = '1.2.14';
18 + public $version = '1.2.6';
20 19 private $php_required = '5.3';
21 20
22 21 private $frontend;
23 22
@@ -27,10 +26,10 @@
27 26 add_action('all_admin_notices', array($this, 'admin_notice_insufficient_php'));
28 27 $abort = true;
29 28 }
30 29
31 - if (!function_exists('mcrypt_get_iv_size') && !function_exists('openssl_cipher_iv_length')) {
32 - 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'));
33 32 $abort = true;
34 33 }
35 34
36 35 if (!empty($abort)) return;
@@ -44,13 +43,8 @@
44 43 add_action('woocommerce_before_customer_login_form', array($this, 'woocommerce_before_customer_login_form'));
45 44 // The login form on the checkout doesn't call the woocommerce_before_customer_login_form action
46 45 add_action('woocommerce_before_checkout_form', array($this, 'woocommerce_before_customer_login_form'));
47 46
48 - add_action('affwp_login_fields_before', array($this, 'affwp_login_fields_before'));
49 - if (!defined('TWO_FACTOR_DISABLE') || !TWO_FACTOR_DISABLE) {
50 - add_action('affwp_process_login_form', array($this, 'affwp_process_login_form'));
51 - }
52 -
53 47 if (is_admin()) {
54 48 //Save settings
55 49 add_action('admin_init', array($this, 'check_possible_reset'));
56 50
@@ -138,13 +132,13 @@
138 132 }
139 133 }
140 134
141 135 public function admin_notice_insufficient_php() {
142 - $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');
143 137 }
144 138
145 - public function admin_notice_missing_mcrypt_and_openssl() {
146 - $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');
147 141 }
148 142
149 143 public function show_admin_warning($message, $class = "updated") {
150 144 echo '<div class="tfamessage '.$class.'">'."<p>$message</p></div>";
@@ -210,26 +204,29 @@
210 204
211 205 // Here's where the login action happens. Called on the 'authenticate' action.
212 206 public function tfaVerifyCodeAndUser($user, $username, $password) {
213 207
208 + $tfa = $this->getTFA();
209 +
214 210 if (is_wp_error($user)) return $user;
215 211
216 - $tfa = $this->getTFA();
217 212 $params = $_POST;
218 213 $params['log'] = $username;
219 214 $params['caller'] = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['REQUEST_URI'];
220 215
221 216 $code_ok = $tfa->authUserFromLogin($params);
217 +
222 218 if (is_wp_error($code_ok)) return $code_ok;
223 219
224 - 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));
225 221
226 222 if ($user) return $user;
227 223
228 224 return wp_authenticate_username_password(null, $username, $password);
229 225 }
230 -
231 - public function tfaRegisterTwoFactorAuthSettings() {
226 +
227 + public function tfaRegisterTwoFactorAuthSettings()
228 + {
232 229 global $wp_roles;
233 230 if (!isset($wp_roles))
234 231 $wp_roles = new WP_Roles();
235 232
@@ -256,13 +253,13 @@
256 253
257 254 if ($tfa->isRequiredForUser($user_id)) {
258 255 $requireafter = absint($this->get_option('tfa_requireafter'));
259 256
260 - 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>';
261 258 }
262 259
263 - $tfa_enabled_label = ($long_label) ? __('Enable two-factor authentication', 'two-factor-authentication') : __('Enabled', 'two-factor-authentication');
264 - $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);
265 262
266 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>';
267 264
268 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>';
@@ -272,9 +269,9 @@
272 269 public function tfaListAlgorithmRadios($user_id)
273 270 {
274 271 if(!$user_id) return;
275 272
276 - $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));
277 274
278 275 $setting = get_user_meta($user_id, 'tfa_algorithm_type', true);
279 276 $setting = $setting === false || !$setting ? 'totp' : $setting;
280 277
@@ -296,9 +293,9 @@
296 293
297 294 if (is_multisite()) {
298 295 // Not a real WP role; needs separate handling
299 296 $id = '_super_admin';
300 - $name = __('Multisite Super Admin', 'two-factor-authentication');
297 + $name = __('Multisite Super Admin', SIMBA_TFA_TEXT_DOMAIN);
301 298 $setting = $this->get_option('tfa_'.$id);
302 299 $setting = $setting === false || $setting ? 1 : 0;
303 300
304 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";
@@ -322,9 +319,9 @@
322 319 $tfa = $this->getTFA();
323 320 $setting = $this->get_option('tfa_default_hmac');
324 321 $setting = $setting === false || !$setting ? $tfa->default_hmac : $setting;
325 322
326 - $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));
327 324
328 325 foreach($types as $id => $name)
329 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";
330 327 }
@@ -335,10 +332,10 @@
335 332 $setting = $this->get_option('tfa_xmlrpc_on');
336 333 $setting = $setting === false || !$setting ? 0 : 1;
337 334
338 335 $types = array(
339 - '0' => __('Do not require 2FA over XMLRPC (best option if you must use XMLRPC and your client does not support 2FA)', 'two-factor-authentication'),
340 - '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)
341 338 );
342 339
343 340 foreach($types as $id => $name)
344 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";
@@ -359,13 +356,11 @@
359 356 public function admin_menu()
360 357 {
361 358 $tfa = $this->getTFA();
362 359
363 - $tfa->potentially_port_private_keys();
364 -
365 360 global $current_user;
366 361 if(!$tfa->isActivatedForUser($current_user->ID)) return;
367 - 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);
368 363 }
369 364
370 365 public function menu_entry_for_admin() {
371 366
@@ -376,10 +371,10 @@
376 371
377 372 add_action( 'admin_init', array($this, 'tfaRegisterTwoFactorAuthSettings' ));
378 373
379 374 add_options_page(
380 - __('Two Factor Authentication', 'two-factor-authentication'),
381 - __('Two Factor Authentication', 'two-factor-authentication'),
375 + __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN),
376 + __('Two Factor Authentication', SIMBA_TFA_TEXT_DOMAIN),
382 377 'manage_options',
383 378 'two-factor-auth',
384 379 array($this, 'tfaShowAdminSettingsPage')
385 380 );
@@ -387,18 +382,18 @@
387 382
388 383 public function addPluginSettingsLink($links)
389 384 {
390 385 if (!is_network_admin()) {
391 - $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>';
392 387 array_unshift($links, $link);
393 388 } else {
394 389 switch_to_blog(1);
395 - $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>';
396 391 restore_current_blog();
397 392 array_unshift($links, $link);
398 393 }
399 394
400 - $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>';
401 396 array_unshift($links, $link2);
402 397
403 398 return $links;
404 399 }
@@ -438,9 +433,9 @@
438 433 $url = $url_base.add_query_arg($add_query_args);
439 434
440 435 $url = wp_nonce_url($url, 'simbatfa_reset_private_key', 'nonce');
441 436
442 - 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>';
443 438
444 439 }
445 440
446 441 public function footer() {
@@ -457,9 +452,9 @@
457 452 "text": $('.simbaotp_qr_container:first').data('qrcode'),
458 453 });
459 454 $('.simbaotp_refresh').click(function(e) {
460 455 e.preventDefault();
461 - $(".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>');
462 457 $.post('<?php echo esc_js($ajax_url);?>', {
463 458 action: "simbatfa_shared_ajax",
464 459 subaction: "refreshotp",
465 460 nonce: "<?php echo esc_js(wp_create_nonce("tfa_shared_nonce"));?>"
@@ -469,9 +464,9 @@
469 464 var resp = $.parseJSON(response);
470 465 got_code = resp.code;
471 466 } catch(err) {
472 467 <?php if (!isset($also_try)) { ?>
473 - alert("<?php echo esc_js(__('Response:', 'two-factor-authentication')); ?> "+response);
468 + alert("<?php echo esc_js(__('Response:', 'SIMBA_TFA_TEXT_DOMAIN')); ?> "+response);
474 469 <?php } ?>
475 470 console.log(response);
476 471 console.log(err);
477 472 }
@@ -491,9 +486,9 @@
491 486 console.log(response);
492 487 console.log("TFA: no code found");
493 488 }
494 489 } catch(err) {
495 - alert("<?php echo esc_js(__('Response:', 'two-factor-authentication')); ?> "+response);
490 + alert("<?php echo esc_js(__('Response:', 'SIMBA_TFA_TEXT_DOMAIN')); ?> "+response);
496 491 console.log(response);
497 492 console.log(err);
498 493 }
499 494 });
@@ -520,18 +515,18 @@
520 515
521 516 $tfa_priv_key_64 = get_user_meta($user_id, 'tfa_priv_key_64', true);
522 517 if(!$tfa_priv_key_64) $tfa_priv_key_64 = $tfa->addPrivateKey($user_id);
523 518
524 - $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));
525 520
526 521 $tfa_priv_key_32 = Base32::encode($tfa_priv_key);
527 522
528 523 if ('full' == $type) {
529 524 ?>
530 - <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>
531 526 <?php echo htmlspecialchars($tfa_priv_key_32); ?><br>
532 527
533 - <strong><?php echo __('Private key:', 'two-factor-authentication');?></strong>
528 + <strong><?php echo __('Private key:', SIMBA_TFA_TEXT_DOMAIN);?></strong>
534 529 <?php echo htmlspecialchars($tfa_priv_key); ?><br>
535 530 <?php
536 531 } elseif ('plain' == $type) {
537 532 echo htmlspecialchars($tfa_priv_key);
@@ -578,9 +573,9 @@
578 573 $tfa_priv_key_64 = get_user_meta($user_id, 'tfa_priv_key_64', true);
579 574
580 575 if(!$tfa_priv_key_64) $tfa_priv_key_64 = $tfa->addPrivateKey($user_id);
581 576
582 - $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));
583 578
584 579 $tfa_priv_key_32 = Base32::encode($tfa_priv_key);
585 580
586 581 $algorithm_type = $tfa->getUserAlgorithm($user_id);
@@ -586,16 +581,16 @@
586 581 $algorithm_type = $tfa->getUserAlgorithm($user_id);
587 582
588 583 if ($admin) {
589 584 if ($current_user->ID == $user_id) {
590 - echo '<h2>'.__('Current codes', 'two-factor-authentication').'</h2>';
585 + echo '<h2>'.__('Current codes', SIMBA_TFA_TEXT_DOMAIN).'</h2>';
591 586 } else {
592 587 $user = get_user_by('id', $user_id);
593 588 $user_descrip = htmlspecialchars($user->user_nicename.' - '.$user->user_email);
594 - 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>';
595 590 }
596 591 } else {
597 -// 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>';
598 593 }
599 594
600 595 ?>
601 596 <div class="postbox">
@@ -601,9 +596,9 @@
601 596 <div class="postbox">
602 597
603 598 <?php if ($admin) { ?>
604 599 <h3 style="padding: 10px 6px 0px; margin:4px 0 0; cursor: default;">
605 - <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).' ';
606 601 if ($current_user->ID == $user_id) { echo $this->reset_current_otp_link(); } ?>
607 602 </span>
608 603 <div class="inside">
609 604 <p><strong style="font-size: 3em;"><?php echo $this->current_otp_code($tfa, $user_id); ?></strong></p>
@@ -613,9 +608,9 @@
613 608 ?>
614 609 <div class="inside">
615 610 <p class="simbatfa-frontend-current-otp" style="font-size: 1.5em; margin-top:6px;">
616 611 <strong>
617 - <?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(); ?>
618 613 </strong> :
619 614
620 615 <span class="simba_current_otp"><?php print $tfa->generateOTP($user_id, $tfa_priv_key_64); ?></span>
621 616
@@ -625,20 +620,20 @@
625 620 <?php } ?>
626 621
627 622 <?php if ($admin) { ?>
628 623 <h3 style="padding-left: 10px; cursor: default;">
629 - <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>
630 625 </h3>
631 626 <?php } else {
632 - echo '<h2>'.__('QR code', 'two-factor-authentication').'</h2>';
627 + echo '<h2>'.__('QR code', SIMBA_TFA_TEXT_DOMAIN).'</h2>';
633 628 } ?>
634 629 <div class="inside">
635 630 <p>
636 - <?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); ?>.
637 632
638 - <?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); ?>.
639 634 </p>
640 - <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);?>">
641 636 <?php $qr_url = $this->tfa_qr_code_url($algorithm_type, $url, $tfa_priv_key) ?>
642 637 <div class="simbaotp_qr_container" data-qrcode="<?php echo esc_attr($qr_url); ?>"></div>
643 638 </p>
644 639 </div>
@@ -644,9 +639,9 @@
644 639 </div>
645 640
646 641 <div class="inside">
647 642
648 - <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>
649 644
650 645 <p>
651 646 <?php
652 647 $this->print_private_keys($admin, 'full', $user_id);
@@ -659,13 +654,13 @@
659 654 if ($admin || apply_filters('simba_tfa_emergency_codes_user_settings', false, $user_id) !== false) {
660 655 ?>
661 656 <div class="inside">
662 657
663 - <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>
664 659
665 660 <p>
666 661 <?php
667 - $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>';
668 663 echo apply_filters('simba_tfa_emergency_codes_user_settings', $default_text, $user_id);
669 664 ?>
670 665 </p>
671 666
@@ -677,9 +672,9 @@
677 672 <?php
678 673 }
679 674
680 675 public function reset_current_otp_link($admin = true) {
681 - return '<a href="#" class="simbaotp_refresh">'.__('(update)', 'two-factor-authentication').'</a>';
676 + return '<a href="#" class="simbaotp_refresh">'.__('(update)', SIMBA_TFA_TEXT_DOMAIN).'</a>';
682 677 }
683 678
684 679 public function advanced_settings_box($submit_button_callback = false) {
685 680 $tfa = $this->getTFA();
@@ -687,15 +682,15 @@
687 682 global $current_user;
688 683 $algorithm_type = $tfa->getUserAlgorithm($current_user->ID);
689 684
690 685 ?>
691 - <h2><?php _e('Advanced settings', 'two-factor-authentication'); ?></h2>
686 + <h2><?php _e('Advanced settings', SIMBA_TFA_TEXT_DOMAIN); ?></h2>
692 687
693 688 <div id="tfa_advanced_box" class="tfa_settings_form" style="margin-top: 20px;">
694 689
695 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 } ?>
696 691
697 - <?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); ?>
698 693 <p>
699 694 <?php
700 695 $this->tfaListAlgorithmRadios($current_user->ID);
701 696 if($algorithm_type == 'hotp')
@@ -700,9 +695,9 @@
700 695 $this->tfaListAlgorithmRadios($current_user->ID);
701 696 if($algorithm_type == 'hotp')
702 697 {
703 698 $counter = $tfa->getUserCounter($current_user->ID);
704 - 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;
705 700 }
706 701 ?>
707 702
708 703 </p>
@@ -721,12 +716,12 @@
721 716
722 717 wp_enqueue_script( 'tfa-ajax-request', SIMBA_TFA_PLUGIN_URL . '/includes/tfa.js', array( 'jquery' ), $script_ver );
723 718 $localize = array(
724 719 'ajaxurl' => admin_url('admin-ajax.php'),
725 - 'click_to_enter_otp' => __("Click to enter One Time Password", 'two-factor-authentication'),
726 - 'enter_username_first' => __('You have to enter a username first.', 'two-factor-authentication'),
727 - 'otp' => __("One Time Password (i.e. 2FA)", 'two-factor-authentication'),
728 - '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),
729 724 'nonce' => wp_create_nonce("simba_tfa_loginform_nonce")
730 725 );
731 726 // Spinner exists since WC 3.8. Use the proper functions to avoid SSL warnings.
732 727 if (file_exists(ABSPATH.'wp-admin/images/spinner.gif')) {
@@ -745,15 +740,15 @@
745 740 return;
746 741
747 742 ?>
748 743 <div class="error">
749 - <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>
750 745 <p>
751 - <?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); ?>
752 747 <br>
753 - <?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);?>
754 749 <br><br>
755 - <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>
756 751 </p>
757 752 </div>
758 753
759 754 <?php
@@ -787,12 +782,12 @@
787 782
788 783 public function settings_intro_notices() {
789 784 ?>
790 785 <p class="simba_tfa_personal_settings_notice simba_tfa_intro_notice">
791 - <?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); ?>
792 787 </p>
793 788 <p class="simba_tfa_verify_tfa_notice simba_tfa_intro_notice"><strong>
794 - <?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 } ?>
795 790 </p>
796 791 <?php
797 792 }
798 793
@@ -797,9 +792,9 @@
797 792 }
798 793
799 794 public function plugins_loaded() {
800 795 load_plugin_textdomain(
801 - 'two-factor-authentication',
796 + SIMBA_TFA_TEXT_DOMAIN,
802 797 false,
803 798 dirname( plugin_basename( __FILE__ ) ) . '/languages/'
804 799 );
805 800 }
@@ -813,47 +808,19 @@
813 808 public function shortcode_when_not_logged_in() {
814 809 return '';
815 810 }
816 811
817 - // Affiliate-WP login form
818 - public function affwp_login_fields_before() {
819 - $this->before_login_form_generic();
820 - }
821 -
822 - public function affwp_process_login_form() {
823 - if (!function_exists('affiliate_wp')) return;
824 - $affiliate_wp = affiliate_wp();
825 - $login = $affiliate_wp->login;
826 -
827 - $tfa = $this->getTFA();
828 - $params = array(
829 - 'log' => (string)$_POST['affwp_user_login'],
830 - 'caller'=> $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['REQUEST_URI'],
831 - 'two_factor_code' => (string)$_POST['two_factor_code']
832 - );
833 - $code_ok = $tfa->authUserFromLogin($params);
834 - if (is_wp_error($code_ok)) {
835 - $login->add_error($code_ok->get_error_code, $code_ok->get_error_message());
836 - } elseif (!$code_ok) {
837 - $login->add_error('authentication_failed', __('Error:', 'two-factor-authentication').' '.__('The one-time password (TFA code) you entered was incorrect.', 'two-factor-authentication'));
838 - }
839 -
840 - }
841 -
842 - // Shared by some 3rd-party login forms
843 - // For historical reasons there are references to WooCommerce in this code - left for the sake of not fixing what was not broken
844 - private function before_login_form_generic() {
845 -
812 + // WooCommerce login form
813 + public function woocommerce_before_customer_login_form() {
846 814 $script_ver = (defined('WP_DEBUG') && WP_DEBUG) ? time() : $this->version;
847 815 wp_enqueue_script( 'tfa-wc-ajax-request', SIMBA_TFA_PLUGIN_URL.'/includes/wooextend.js', array('jquery'), $script_ver);
848 -
849 816 $localize = array(
850 817 'ajaxurl' => admin_url('admin-ajax.php'),
851 - 'click_to_enter_otp' => __("Enter One Time Password (if you have one)", 'two-factor-authentication'),
852 - 'enter_username_first' => __('You have to enter a username first.', 'two-factor-authentication'),
853 - '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),
854 821 'nonce' => wp_create_nonce("simba_tfa_loginform_nonce"),
855 - '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),
856 823 );
857 824 // Spinner exists since WC 3.8. Use the proper functions to avoid SSL warnings.
858 825 if (file_exists(ABSPATH.'wp-admin/images/spinner.gif')) {
859 826 $localize['spinnerimg'] = admin_url('images/spinner.gif');
@@ -861,13 +828,8 @@
861 828 $localize['spinnerimg'] = includes_url('images/spinner.gif');
862 829 }
863 830
864 831 wp_localize_script( 'tfa-wc-ajax-request', 'simbatfa_wc_settings', $localize);
865 - }
866 -
867 - // WooCommerce login form
868 - public function woocommerce_before_customer_login_form() {
869 - $this->before_login_form_generic();
870 832 }
871 833
872 834 }
873 835