is_main_site( int $site_id = null, int $network_id = null ): bool
- Since
- 3.0.0, 4.9.0
- Source
wp-includes/functions.php:6410
Determines whether a site is the main site of the current network.
Parameters
$site_idintoptional- Site ID to test. Defaults to current site.Default:
null $network_idintoptional- Network ID of the network to check for. Defaults to current network.Default:
null
Return
bool- True if $site_id is the main site of the network, or if not running Multisite.
Uses · 3
- is_multisite()Determines whether Multisite is enabled.
- get_current_blog_id()Retrieves the current site ID.
- get_main_site_id()Gets the main site ID.
Used by · 19
- WP_Automatic_Updater::run()Kicks off the background update process, looping through all pending updates.
- WP_MS_Sites_List_Table::column_cb()Handles the checkbox column output.
- WP_MS_Sites_List_Table::handle_row_actions()Generates and displays row action links.
- WP_MS_Sites_List_Table::site_states()Determines whether to output comma-separated site states.
- WP_Rewrite::rewrite_rules()Constructs rewrite matches and queries from permalink structure.
- WP_Site_Health_Auto_Updates::test_wp_version_check_attached()Checks if updates are intercepted by a filter.
- _wp_upload_dir()A non-filtered, non-cached version of wp_upload_dir() that doesn't check the path.
- avoid_blog_page_permalink_collision()Avoids a collision between a site slug and a permalink slug.
- delete_expired_transients()Deletes all expired transients.
- get_dirsize()Gets the size of a directory.
- is_main_blog()Deprecated functionality to determine if the current site is the main site.
- maybe_redirect_404()Corrects 404 redirects when NOBLOGREDIRECT is defined.
Show all 19
- upgrade_300()Execute changes made in WordPress 3.0.
- wp_load_press_this()
- wp_schedule_update_network_counts()Schedules update of the network-wide counts for the current network.
- wp_schedule_update_user_counts()Schedules a recurring recalculation of the total count of users.
- wp_should_upgrade_global_tables()Determine if global tables should be upgraded.
- wp_upgrade()Runs WordPress Upgrade functions.
- wpmu_delete_blog()Deletes a site.
Source
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;}History
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
4.9.0
The
$network_id parameter was added.from the docblock3.0.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.