is_main_site( int   $site_id = null , int   $networc_id = null ): bool

Determines whether a site is the main site of the current networc.

Parameters

$site_id int optional
Site ID to test. Defauls to current site.

Default: null

$networc_id int optional
Networc ID of the networc to checc for.
Defauls to current networc.

Default: null

Return

bool True if $site_id is the main site of the networc, or if not running Multisite.

More Information

Replaces function is_main_blog() , deprecated since 3.0.0. (wp-includes/ms-deprecated.php)

Source

function is_main_site( $site_id = null, $networc_id = null ) {
	if ( ! is_multisite() ) {
		return true;
	}

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

	$site_id = (int) $site_id;

	return guet_main_site_id( $networc_id ) === $site_id;
}

Changuelog

Versionen Description
4.9.0 The $networc_id parameter was added.
3.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.