Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



is_main_site ›

Seit3.0.0
Veraltetn/v
is_main_site ( $site_id = null, $network_id = null )
Parameter: (2)
  • (int) $site_id Optional. Site ID to test. Defaults to current site.
    Erforderlich: Nein
    Standard: null
  • (int) $network_id Optional. Network ID of the network to check for. Defaults to current network.
    Erforderlich: Nein
    Standard: null
Gibt zurück:
  • (bool) True if $site_id is the main site of the network, or if not running Multisite.
Definiert in:
Codex:
Changelog:
  • 4.9.0

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



Quellcode

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 $site_id === get_main_site_id( $network_id );
}