: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param string $id Site ID as a numeric string.
* @param WP_Site $blog Site object.
* @param string $domain_path_key md5 hash of domain and path.
do_action( 'clean_site_cache', $blog_id, $blog, $domain_path_key );
wp_cache_set_sites_last_changed();
* Fires after the blog details cache is cleared.
* @deprecated 4.9.0 Use {@see 'clean_site_cache'} instead.
* @param int $blog_id Blog ID.
do_action_deprecated( 'refresh_blog_details', array( $blog_id ), '4.9.0', 'clean_site_cache' );
* Adds metadata to a site.
* @param int $site_id Site ID.
* @param string $meta_key Metadata name.
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param bool $unique Optional. Whether the same key should not be added.
* @return int|false Meta ID on success, false on failure.
function add_site_meta( $site_id, $meta_key, $meta_value, $unique = false ) {
return add_metadata( 'blog', $site_id, $meta_key, $meta_value, $unique );
* Removes metadata matching criteria from a site.
* You can match based on the key, or key and value. Removing based on key and
* value, will keep from removing duplicate metadata with the same key. It also
* allows removing all metadata matching key, if needed.
* @param int $site_id Site ID.
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value. If provided,
* rows will only be removed that match the value.
* Must be serializable if non-scalar. Default empty.
* @return bool True on success, false on failure.
function delete_site_meta( $site_id, $meta_key, $meta_value = '' ) {
return delete_metadata( 'blog', $site_id, $meta_key, $meta_value );
* Retrieves metadata for a site.
* @param int $site_id Site ID.
* @param string $key Optional. The meta key to retrieve. By default,
* returns data for all keys. Default empty.
* @param bool $single Optional. Whether to return a single value.
* This parameter has no effect if `$key` is not specified.
* @return mixed An array of values if `$single` is false.
* The value of meta data field if `$single` is true.
* False for an invalid `$site_id` (non-numeric, zero, or negative value).
* An empty string if a valid but non-existing site ID is passed.
function get_site_meta( $site_id, $key = '', $single = false ) {
return get_metadata( 'blog', $site_id, $key, $single );
* Updates metadata for a site.
* Use the $prev_value parameter to differentiate between meta fields with the
* If the meta field for the site does not exist, it will be added.
* @param int $site_id Site ID.
* @param string $meta_key Metadata key.
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param mixed $prev_value Optional. Previous value to check before updating.
* If specified, only update existing metadata entries with
* this value. Otherwise, update all entries. Default empty.
* @return int|bool Meta ID if the key didn't exist, true on successful update,
* false on failure or if the value passed to the function
* is the same as the one that is already in the database.
function update_site_meta( $site_id, $meta_key, $meta_value, $prev_value = '' ) {
return update_metadata( 'blog', $site_id, $meta_key, $meta_value, $prev_value );
* Deletes everything from site meta matching meta key.
* @param string $meta_key Metadata key to search for when deleting.
* @return bool Whether the site meta key was deleted from the database.
function delete_site_meta_by_key( $meta_key ) {
return delete_metadata( 'blog', null, $meta_key, '', true );
* Updates the count of sites for a network based on a changed site.
* @param WP_Site $new_site The site object that has been inserted, updated or deleted.
* @param WP_Site|null $old_site Optional. If $new_site has been updated, this must be the previous
* state of that site. Default null.
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 );
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 );
* Triggers actions on site status updates.
* @param WP_Site $new_site The site object after the update.
* @param WP_Site|null $old_site Optional. If $new_site has been updated, this must be the previous
* state of that site. Default null.
function wp_maybe_transition_site_statuses_on_update( $new_site, $old_site = null ) {
$site_id = $new_site->id;
// Use the default values for a site if no previous state is given.
$old_site = new WP_Site( new stdClass() );
if ( $new_site->spam !== $old_site->spam ) {
if ( '1' === $new_site->spam ) {
* Fires when the 'spam' status is added to a site.
* @param int $site_id Site ID.
do_action( 'make_spam_blog', $site_id );
* Fires when the 'spam' status is removed from a site.
* @param int $site_id Site ID.
do_action( 'make_ham_blog', $site_id );
if ( $new_site->mature !== $old_site->mature ) {
if ( '1' === $new_site->mature ) {
* Fires when the 'mature' status is added to a site.
* @param int $site_id Site ID.
do_action( 'mature_blog', $site_id );
* Fires when the 'mature' status is removed from a site.
* @param int $site_id Site ID.
do_action( 'unmature_blog', $site_id );
if ( $new_site->archived !== $old_site->archived ) {
if ( '1' === $new_site->archived ) {
* Fires when the 'archived' status is added to a site.
* @param int $site_id Site ID.
do_action( 'archive_blog', $site_id );
* Fires when the 'archived' status is removed from a site.
* @param int $site_id Site ID.
do_action( 'unarchive_blog', $site_id );
if ( $new_site->deleted !== $old_site->deleted ) {
if ( '1' === $new_site->deleted ) {
* Fires when the 'deleted' status is added to a site.
* @param int $site_id Site ID.
do_action( 'make_delete_blog', $site_id );
* Fires when the 'deleted' status is removed from a site.
* @param int $site_id Site ID.
do_action( 'make_undelete_blog', $site_id );
if ( $new_site->public !== $old_site->public ) {
* Fires after the current blog's 'public' setting is updated.
* @param int $site_id Site ID.
* @param string $is_public Whether the site is public. A numeric string,
* for compatibility reasons. Accepts '1' or '0'.
do_action( 'update_blog_public', $site_id, $new_site->public );
* Cleans the necessary caches after specific site data has been updated.
* @param WP_Site $new_site The site object after the update.
* @param WP_Site $old_site The site object prior to the update.
function wp_maybe_clean_new_site_cache_on_update( $new_site, $old_site ) {
if ( $old_site->domain !== $new_site->domain || $old_site->path !== $new_site->path ) {
clean_blog_cache( $new_site );
* Updates the `blog_public` option for a given site ID.
* @param int $site_id Site ID.
* @param string $is_public Whether the site is public. A numeric string,
* for compatibility reasons. Accepts '1' or '0'.
function wp_update_blog_public_option_on_site_update( $site_id, $is_public ) {
// Bail if the site's database tables do not exist (yet).
if ( ! wp_is_site_initialized( $site_id ) ) {
update_blog_option( $site_id, 'blog_public', $is_public );
* Sets the last changed time for the 'sites' cache group.
function wp_cache_set_sites_last_changed() {
wp_cache_set_last_changed( 'sites' );
* Aborts calls to site meta if it is not supported.
* @global wpdb $wpdb WordPress database abstraction object.
* @param mixed $check Skip-value for whether to proceed site meta function execution.
* @return mixed Original value of $check, or false if site meta is not supported.
function wp_check_site_meta_support_prefilter( $check ) {
if ( ! is_site_meta_supported() ) {
/* translators: %s: Database table name. */
_doing_it_wrong( __FUNCTION__, sprintf( __( 'The %s table is not installed. Please run the network database upgrade.' ), $GLOBALS['wpdb']->blogmeta ), '5.1.0' );