is_registered( 'openrouter' ) ) { return; } $registry->register( 'openrouter', self::getConnectorStruct() ); } /** * Returns the canonical connector struct for OpenRouter. * * Extracted as a public method so test code can introspect the struct shape * independently without invoking the registry. * * Struct shape mirrors the built-in AI provider connectors defined in * wp-includes/connectors.php lines 286–322. The setting_name, constant_name, * and env_var_name fields are provided explicitly here following the naming * pattern that _wp_connectors_register_default_ai_providers() auto-generates * for built-ins (wp-includes/connectors.php lines 384–393): * * setting_name → connectors_ai_{id}_api_key * constant_name → {UPPERCASE_ID}_API_KEY * env_var_name → {UPPERCASE_ID}_API_KEY * * @since 2.6.0 * * @return array Connector struct compatible with WP_Connector_Registry::register(). */ public static function getConnectorStruct(): array { return array( 'name' => 'OpenRouter', 'description' => __( 'Multi-model AI aggregator (Claude, GPT, Llama, and more).', 'ai-product-tools' ), 'type' => 'ai_provider', 'logo_url' => plugins_url( 'src/Assets/images/connectors/openrouter.svg', \AIPT_PLUGIN_FILE ), 'authentication' => array( 'method' => 'api_key', 'credentials_url' => 'https://openrouter.ai/keys', 'setting_name' => 'connectors_ai_openrouter_api_key', 'constant_name' => 'OPENROUTER_API_KEY', 'env_var_name' => 'OPENROUTER_API_KEY', ), 'plugin' => array( 'file' => plugin_basename( \AIPT_PLUGIN_FILE ), ), ); } }