> */ const ADAPTERS = array( Integrations\Contact_Form_7::class, Integrations\Wpforms::class, Integrations\Gravity_Forms::class, Integrations\Elementor_Forms::class, Integrations\Fluent_Forms::class, Integrations\Ninja_Forms::class, Integrations\Formidable::class, ); /** @var array|null */ private static $all = null; /** * Every adapter, keyed by slug, whether or not its plugin is active. * * @return array */ public static function all() { if ( null === self::$all ) { self::$all = array(); foreach ( self::ADAPTERS as $class ) { // A missing adapter file must never take the site down. if ( ! class_exists( $class ) ) { continue; } $adapter = new $class(); self::$all[ $adapter->slug() ] = $adapter; } } return self::$all; } /** * The adapters whose form plugin is active on this site. * * @return array */ public static function available() { return array_filter( self::all(), static function ( Integration $adapter ) { return $adapter->is_available(); } ); } /** * One adapter by slug. * * @param string $slug The adapter's slug. * @return Integration|null */ public static function get( $slug ) { $all = self::all(); return isset( $all[ $slug ] ) ? $all[ $slug ] : null; } /** * Add every active adapter's submission hook. Called once on `plugins_loaded` (late priority, so * the form plugins have loaded), and only while the site is connected. * * @return void */ public static function register() { foreach ( self::available() as $adapter ) { $adapter->register(); } } }