# domain_exists()

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

Тип: функция.
Появился в версии: MU (3.0.0).

## Сигнатура

```php
domain_exists( string $domain, string $path, int $network_id = 1 ): int|null
```

## Описание

Имя — это поддомен сайта или путь подкаталога сайта в зависимости от настроек сети.
Используется в процессе регистрации нового сайта, чтобы гарантировать уникальность каждого имени сайта.

## Параметры

- `$domain` `string` — обязательный. Домен для проверки.
- `$path` `string` — обязательный. Путь для проверки.
- `$network_id` `int` — необязательный, по умолчанию `1`. ID сети. Актуально только на установках с несколькими сетями.

## Возвращаемое значение

`int|null`

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

Файл: `wp-includes/ms-functions.php:1591`

```php
function domain_exists( $domain, $path, $network_id = 1 ) {
	$path   = trailingslashit( $path );
	$args   = array(
		'network_id'             => $network_id,
		'domain'                 => $domain,
		'path'                   => $path,
		'fields'                 => 'ids',
		'number'                 => 1,
		'update_site_meta_cache' => false,
	);
	$result = get_sites( $args );
	$result = array_shift( $result );

	/**
	 * Filters whether a site name is taken.
	 *
	 * The name is the site's subdomain or the site's subdirectory
	 * path depending on the network settings.
	 *
	 * @since 3.5.0
	 *
	 * @param int|null $result     The site ID if the site name exists, null otherwise.
	 * @param string   $domain     Domain to be checked.
	 * @param string   $path       Path to be checked.
	 * @param int      $network_id Network ID. Only relevant on multi-network installations.
	 */
	return apply_filters( 'domain_exists', $result, $domain, $path, $network_id );
}
```

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

- MU (3.0.0) — Introduced.

## Связанные

Использует: [`get_sites`](https://chugunov.pro/api-wordpress/functions/get_sites/), [`trailingslashit`](https://chugunov.pro/api-wordpress/functions/trailingslashit/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wp_validate_site_data`](https://chugunov.pro/api-wordpress/functions/wp_validate_site_data/), [`wpmu_create_blog`](https://chugunov.pro/api-wordpress/functions/wpmu_create_blog/), [`wpmu_validate_blog_signup`](https://chugunov.pro/api-wordpress/functions/wpmu_validate_blog_signup/), [`create_empty_blog`](https://chugunov.pro/api-wordpress/functions/create_empty_blog/).

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