domain_exists
Check whether a blogname is already taken.
Description
Used during the new site registration process to ensure that each blogname is unique.
Returns (int)
Parameters (3)
- 0. $domain (string)
- The domain to be checked.
- 1. $path (string)
- The path to be checked.
- 2. $site_id — Optional. (int) =>
1
- Relevant only on multi-network installs.
Usage
if ( !function_exists( 'domain_exists' ) ) { require_once ABSPATH . WPINC . '/ms-functions.php'; } // The domain to be checked. $domain = ''; // The path to be checked. $path = ''; // Optional. Relevant only on multi-network installs. $site_id = 1; // NOTICE! Understand what this does before running. $result = domain_exists($domain, $path, $site_id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/ms-functions.php
- function domain_exists($domain, $path, $site_id = 1) {
- $path = trailingslashit( $path );
- $args = array(
- 'network_id' => $site_id,
- 'domain' => $domain,
- 'path' => $path,
- 'fields' => 'ids',
- );
- $result = get_sites( $args );
- $result = array_shift( $result );
- /**
- * Filters whether a blogname is taken.
- *
- * @since 3.5.0
- *
- * @param int|null $result The blog_id if the blogname exists, null otherwise.
- * @param string $domain Domain to be checked.
- * @param string $path Path to be checked.
- * @param int $site_id Site ID. Relevant only on multi-network installs.
- */
- return apply_filters( 'domain_exists', $result, $domain, $path, $site_id );
- }