On this page
is_main_network( int $network_id = null ): bool
Determines whether a network is the main network of the Multisite installation.
Parameters
$network_idint Optional-
Network ID to test. Defaults to current network.
Default:
null
Return
bool True if $network_id is the main network, or if not running Multisite.
Source
File: wp-includes/functions.php. View all references
function is_main_network( $network_id = null ) {
if ( ! is_multisite() ) {
return true;
}
if ( null === $network_id ) {
$network_id = get_current_network_id();
}
$network_id = (int) $network_id;
return ( get_main_network_id() === $network_id );
}
Related
Uses
| Uses | Description |
|---|---|
| get_current_network_id() wp-includes/load.php | Retrieves the current network ID. |
| get_main_network_id() wp-includes/functions.php | Gets the main network ID. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
Used By
| Used By | Description |
|---|---|
| delete_expired_transients() wp-includes/option.php | Deletes all expired transients. |
| _wp_upload_dir() wp-includes/functions.php | A non-filtered, non-cached version of wp_upload_dir() that doesn’t check the path. |
| wp_should_upgrade_global_tables() wp-admin/includes/upgrade.php | Determine if global tables should be upgraded. |
| WP_Automatic_Updater::run() wp-admin/includes/class-wp-automatic-updater.php | Kicks off the background update process, looping through all pending updates. |
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_main_network