wp_maybe_update_network_site_counts_on_update() WordPress Function

The wp_maybe_update_network_site_counts_on_update() function is used to update the site count for a network when a new site is created or an existing site is updated. This function is only used for networks that have the "Enable network site counting" setting enabled.

wp_maybe_update_network_site_counts_on_update( WP_Site $new_site, WP_Site|null $old_site = null ) #

Updates the count of sites for a network based on a changed site.


Parameters

$new_site

(WP_Site)(Required)The site object that has been inserted, updated or deleted.

$old_site

(WP_Site|null)(Optional) If $new_site has been updated, this must be the previous state of that site.

Default value: null


Top ↑

Source

File: wp-includes/ms-site.php

function wp_maybe_update_network_site_counts_on_update( $new_site, $old_site = null ) {
	if ( null === $old_site ) {
		wp_maybe_update_network_site_counts( $new_site->network_id );
		return;
	}

	if ( $new_site->network_id != $old_site->network_id ) {
		wp_maybe_update_network_site_counts( $new_site->network_id );
		wp_maybe_update_network_site_counts( $old_site->network_id );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.