# _wp_connectors_init()

URL: https://chugunov.pro/api-wordpress/functions/_wp_connectors_init/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 7.0.0.

## Сигнатура

```php
_wp_connectors_init()
```

## Описание

Создаёт экземпляр реестра, регистрирует встроенные коннекторы (которые нельзя отключить) и затем запускает действие wp_connectors_init, чтобы плагины могли зарегистрировать собственные коннекторы.

## Исходный код

Файл: `wp-includes/connectors.php:212`

```php
function _wp_connectors_init(): void {
	$registry = new WP_Connector_Registry();
	WP_Connector_Registry::set_instance( $registry );

	// Only register default AI providers if AI support is enabled.
	if ( wp_supports_ai() ) {
		_wp_connectors_register_default_ai_providers( $registry );
	}

	// Non-AI default connectors.
	$registry->register(
		'akismet',
		array(
			'name'           => __( 'Akismet Anti-spam' ),
			'description'    => __( 'Protect your site from spam.' ),
			'type'           => 'spam_filtering',
			'plugin'         => array(
				'file'      => 'akismet/akismet.php',
				'is_active' => static function () {
					return defined( 'AKISMET_VERSION' );
				},
			),
			'authentication' => array(
				'method'          => 'api_key',
				'credentials_url' => 'https://akismet.com/get/',
				'setting_name'    => 'wordpress_api_key',
				'constant_name'   => 'WPCOM_API_KEY',
			),
		)
	);

	/**
	 * Fires when the connector registry is ready for plugins to register connectors.
	 *
	 * Built-in connectors and any AI providers auto-discovered from the WP AI Client
	 * registry have already been registered at this point and cannot be unhooked.
	 *
	 * AI provider plugins that register with the WP AI Client do not need to use
	 * this action — their connectors are created automatically. This action is
	 * primarily for registering non-AI-provider connectors or overriding metadata
	 * on existing connectors.
	 *
	 * Use `$registry->register()` within this action to add new connectors.
	 * To override an existing connector, unregister it first, then re-register
	 * with updated data.
	 *
	 * Example — overriding metadata on an auto-discovered connector:
	 *
	 *     add_action( 'wp_connectors_init', function ( WP_Connector_Registry $registry ) {
	 *         if ( $registry->is_registered( 'anthropic' ) ) {
	 *             $connector = $registry->unregister( 'anthropic' );
	 *             $connector['description'] = __( 'Custom description for Anthropic.', 'my-plugin' );
	 *             $registry->register( 'anthropic', $connector );
	 *         }
	 *     } );
	 *
	 * @since 7.0.0
	 *
	 * @param WP_Connector_Registry $registry Connector registry instance.
	 */
	do_action( 'wp_connectors_init', $registry );
}
```

## История изменений

- 7.0.0 — Introduced.

## Связанные

Использует: [`_wp_connectors_register_default_ai_providers`](https://chugunov.pro/api-wordpress/functions/_wp_connectors_register_default_ai_providers/), `WP_Connector_Registry::set_instance`, [`wp_supports_ai`](https://chugunov.pro/api-wordpress/functions/wp_supports_ai/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/_wp_connectors_init/
