Skip to content

Commit

Permalink
fix: make Two Factor more deploy-friendly (#6127)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks authored Feb 4, 2025
1 parent 91a9c0f commit 974b4a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class Two_Factor_Backup_Codes extends Two_Factor_Provider {
*/
const NUMBER_OF_CODES = 10;

public static function get_instance() {
static $instance;
$class = __CLASS__;
if ( ! is_a( $instance, $class ) ) {
$instance = new $class();
}
return $instance;
}

/**
* Class constructor.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class Two_Factor_Email extends Two_Factor_Provider {
*/
const INPUT_NAME_RESEND_CODE = 'two-factor-email-code-resend';

public static function get_instance() {
static $instance;
$class = __CLASS__;
if ( ! is_a( $instance, $class ) ) {
$instance = new $class();
}
return $instance;
}

/**
* Class constructor.
*
Expand Down
9 changes: 9 additions & 0 deletions shared-plugins/two-factor/providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ class Two_Factor_Totp extends Two_Factor_Provider {
*/
private static $base_32_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';

public static function get_instance() {
static $instance;
$class = __CLASS__;
if ( ! is_a( $instance, $class ) ) {
$instance = new $class();
}
return $instance;
}

/**
* Class constructor. Sets up hooks, etc.
*
Expand Down

0 comments on commit 974b4a4

Please sign in to comment.