wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



domain_exists › WordPress Function

Desde
Obsoleton/a
domain_exists ( $domain, $path, $network_id = 1 )
Parâmetros: (3)
  • (string) $domain The domain to be checked.
    Required: Yes
  • (string) $path The path to be checked.
    Required: Yes
  • (int) $network_id Optional. Network ID. Only relevant on multi-network installations. Default 1.
    Required: No
    Padrão: 1
Retorna:
  • (int|null) The site ID if the site name exists, null otherwise.
Definido em:
Codex:
Log de mudanças:
  • MU

Checks whether a site name is already taken.

The name is the site's subdomain or the site's subdirectory path depending on the network settings. Used during the new site registration process to ensure that each site name is unique.


Fonte

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 );
}