WordPress at a glance

is_main_site() WP 1.0

Determine whether a site is the main site of the current network.

Возвращает

true/false. True if $site_id is the main site of the network, or if not running Multisite.

1 time = 0.000013s = very fast | 50000 times = 0.045192s = speed of light

No Hooks.

Usage

is_main_site( $site_id, $network_id );
$site_id(int)
Site ID to test.
Default: current site
$network_id(int)
Network ID of the network to check for.
Default: current network

Список изменений

С версии 3.0.0 Введена.
С версии 4.9.0 The $network_id parameter was added.

Code of is_main_site() WP 5.5.1

wp-includes/functions.php
<?php
function is_main_site( $site_id = null, $network_id = null ) {
	if ( ! is_multisite() ) {
		return true;
	}

	if ( ! $site_id ) {
		$site_id = get_current_blog_id();
	}

	$site_id = (int) $site_id;

	return get_main_site_id( $network_id ) === $site_id;
}

Related Functions

From category: Multisite

No comments
    Log In . Register