manager = Manager::instance(); $this->init_hooks(); } /** * Get the correct filename suffix for minified assets. * * @since 1.0.0 * * @return string */ public function minified_asset_suffix() { $ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; return $ext; } /** * When WP has loaded all plugins, trigger the `brain_2fa_loaded` hook. * * This ensures `brain_2fa_loaded` is called only after all other plugins * are loaded, to avoid issues caused by plugin directory naming changing * the load order. * * @since 1.0.0 * * @return void */ public function on_plugins_loaded() { Install::maybe_upgrade(); $this->manager->register_method( new TotpMethod() ); $this->manager->register_method( new EmailMethod() ); // Initialize login handler. LoginController::init(); LoginAssets::init(); AccountEvents::init(); EnrollmentGuard::init(); PasskeyRepository::init(); if ( Utils::is_passkeys_enabled() ) { PasskeyLogin::init(); PasskeyRegistration::init(); } // Initialize admin classes. if ( is_admin() ) { $this->admin_settings = Settings::instance(); $this->admin_user_profile = UserProfile::instance(); $this->admin_assets = Assets::instance(); $this->admin_user_columns = UserListColumns::instance(); EmailSettings::init(); } do_action( 'brain_2fa_loaded' ); } /** * Hook into actions and filters. * * @since 1.0.0 * * @return void */ private function init_hooks() { add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ), PHP_INT_MAX ); } /** * Cloning is forbidden. * * @since 1.0.0 */ public function __clone() { _doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'brain-2fa' ), '1.0.0' ); } /** * Unserializing instances of this class is forbidden. * * @since 1.0.0 */ public function __wakeup() { _doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'brain-2fa' ), '1.0.0' ); } }