Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U2F: Don't trigger a PHP warning about U2F if it's not in use. #219

Merged
merged 1 commit into from Feb 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions class.two-factor-core.php
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