maybe_load_wp_two_factor_bridge(); } /** * In-form Two Factor on AMem login. DEV-only; otherwise Two Factor uses wp-login.php. * * @since 1.3.0 * * @return bool */ public static function is_login_form_integration_enabled() { if ( ! function_exists( 'amem' ) || ! amem()->is_dev() ) { return false; } if ( ! amem()->options->getmodule( '_use_2fa' ) ) { return false; } return class_exists( 'Two_Factor_Core' ); } /** * WordPress.org Two Factor plugin: in-form challenge on AMem login (no wp-login redirect). */ protected function maybe_load_wp_two_factor_bridge() { if ( $this->bridge ) { return; } if ( ! self::is_login_form_integration_enabled() ) { return; } amem_include( 'core/modules/2fa/class-two-factor-bridge.php' ); $this->bridge = Two_Factor_Bridge::get_instance(); } /** * Delegates to the WordPress Two Factor bridge when it is active. * * @param array $form Form. * @param int $rememberme Remember flag. * @param \AMem\Action\Login $login_action Login action. * @return bool True when the bridge handled the request (step 1 challenge or step 2 complete). */ public function handle_auto_login( $form, $rememberme, $login_action ) { if ( ! self::is_login_form_integration_enabled() ) { return false; } $this->maybe_load_wp_two_factor_bridge(); if ( ! $this->bridge ) { return false; } return $this->bridge->handle_auto_login( $form, (int) $rememberme, $login_action ); } } amem()->register_module( 'twofactor', TwoFactor::class );