Skip to content

Commit

Permalink
U2F: Don't trigger a PHP warning about U2F if it's not in use.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Feb 25, 2018
1 parent f3eb6fe commit 2e14e4e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions class.two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ public static function get_providers() {
'Two_Factor_Dummy' => TWO_FACTOR_DIR . 'providers/class.two-factor-dummy.php',
);

// FIDO U2F is PHP 5.3+ only.
if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
unset( $providers['Two_Factor_FIDO_U2F'] );
trigger_error( sprintf( // WPCS: XSS OK.
__( 'FIDO U2F is not available because you are using PHP %s. (Requires 5.3 or greater)' ),
PHP_VERSION
) );
}

/**
* Filter the supplied providers.
*
Expand All @@ -93,6 +84,15 @@ public static function get_providers() {
*/
$providers = apply_filters( 'two_factor_providers', $providers );

// FIDO U2F is PHP 5.3+ only.
if ( isset( $providers['Two_Factor_FIDO_U2F'] ) && version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
unset( $providers['Two_Factor_FIDO_U2F'] );
trigger_error( sprintf( // WPCS: XSS OK.
__( 'FIDO U2F is not available because you are using PHP %s. (Requires 5.3 or greater)' ),
PHP_VERSION
) );
}

/**
* For each filtered provider,
*/
Expand Down

0 comments on commit 2e14e4e

Please sign in to comment.