This commit is contained in:
Javier Casares 2026-03-28 09:59:53 +00:00
commit 71b471e13e
19 changed files with 771 additions and 60 deletions

View file

@ -157,7 +157,15 @@ class Two_Factor_Extended_Enforcement {
// If site override is not allowed, return only network requirements.
if ( empty( $network_settings['allow_site_override'] ) ) {
return array_values( array_unique( $required ) );
$network_required = array_values( array_unique( $required ) );
// Intersect with globally-available providers (Two Factor 0.16+).
if ( class_exists( 'Two_Factor_Core' ) ) {
$available = array_keys( Two_Factor_Core::get_providers() );
$network_required = ! empty( $available ) ? array_values( array_intersect( $network_required, $available ) ) : $network_required;
}
return $network_required;
}
}
}
@ -185,7 +193,19 @@ class Two_Factor_Extended_Enforcement {
}
}
return array_values( array_unique( $required ) );
$required = array_values( array_unique( $required ) );
// Intersect with globally-available providers (Two Factor 0.16+).
// If Two-Factor has disabled a provider site-wide, it cannot be enforced.
if ( class_exists( 'Two_Factor_Core' ) ) {
$available = array_keys( Two_Factor_Core::get_providers() );
if ( ! empty( $available ) ) {
$required = array_values( array_intersect( $required, $available ) );
}
}
return $required;
}
/**
@ -316,7 +336,7 @@ class Two_Factor_Extended_Enforcement {
?>
<div class="notice notice-warning">
<p>
<strong><?php esc_html_e( 'Two Factor Extended:', 'two-factor-extended' ); ?></strong>
<strong><?php esc_html_e( 'Two-Factor Extended:', 'two-factor-extended' ); ?></strong>
<?php
printf(
esc_html(
@ -344,7 +364,7 @@ class Two_Factor_Extended_Enforcement {
?>
<div class="notice notice-error">
<p>
<strong><?php esc_html_e( 'Two Factor Extended:', 'two-factor-extended' ); ?></strong>
<strong><?php esc_html_e( 'Two-Factor Extended:', 'two-factor-extended' ); ?></strong>
<?php
printf(
/* translators: %s: Required providers list */