wppaste
WordPress

populate_site_meta( int $site_id, array $meta = array() )

Since
5.1.0
Source
wp-admin/includes/schema.php:1384
Creates WordPress site meta and sets the default values.

Parameters

$site_idint
Site ID to populate meta for.
$metaarrayoptional
Custom meta $key => $value pairs to use. Default empty array.Default: array()

Hooks fired · 1

One hook fires while populate_site_meta() runs, in this order:

  1. apply_filters( populate_site_meta )filterline 1405 (+21 into the body)

    Filters meta for a site on creation.

Uses · 4

Used by · 1

Source

function populate_site_meta( $site_id, array $meta = array() ) {	global $wpdb; 	$site_id = (int) $site_id; 	if ( ! is_site_meta_supported() ) {		return;	} 	if ( empty( $meta ) ) {		return;	} 	/**	 * Filters meta for a site on creation.	 *	 * @since 5.2.0	 *	 * @param array $meta    Associative array of site meta keys and values to be inserted.	 * @param int   $site_id ID of site to populate.	 */	$site_meta = apply_filters( 'populate_site_meta', $meta, $site_id ); 	$insert = '';	foreach ( $site_meta as $meta_key => $meta_value ) {		if ( is_array( $meta_value ) ) {			$meta_value = serialize( $meta_value );		}		if ( ! empty( $insert ) ) {			$insert .= ', ';		}		$insert .= $wpdb->prepare( '( %d, %s, %s)', $site_id, $meta_key, $meta_value );	} 	$wpdb->query( "INSERT INTO $wpdb->blogmeta ( blog_id, meta_key, meta_value ) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 	wp_cache_delete( $site_id, 'blog_meta' );	wp_cache_set_sites_last_changed();}

History

Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/schema.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.