id() ] = $superpdp; /** * Register additional connectors (e.g. the paid "managed" relay connector). * * @param EFacture_FR_Connector[] $connectors Map of id => connector. */ $connectors = apply_filters( 'efacture_fr_connectors', $connectors ); // Keep only valid implementations. return array_filter( $connectors, static function ( $c ) { return $c instanceof EFacture_FR_Connector; } ); } /** * The connector that should handle transmission right now. * * Defaults to the selected one (or the first configured one). A paid add-on * can override the choice via the `efacture_fr_active_connector` filter. * * @return EFacture_FR_Connector|null */ public static function active() { $all = self::all(); if ( empty( $all ) ) { return null; } $selected = (string) get_option( 'efacture_fr_connector', 'superpdp' ); $active = isset( $all[ $selected ] ) ? $all[ $selected ] : null; if ( ! $active || ! $active->is_configured() ) { // Fall back to the first configured connector. foreach ( $all as $c ) { if ( $c->is_configured() ) { $active = $c; break; } } } /** * Override the active connector. * * @param EFacture_FR_Connector|null $active The chosen connector. * @param EFacture_FR_Connector[] $all All registered connectors. */ return apply_filters( 'efacture_fr_active_connector', $active, $all ); } }