populate_site_meta()

 

File: wp-admin/includes/schema.php

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;
	}

	$insert = '';
	foreach ( $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();
}

参数:populate_site_meta( int $site_id, array $meta = array() )

Site ID to populate meta for. Custom meta $key => $value pairs to use.

$site_id

(int)
(Required)
Site ID to populate meta for.

$meta

(array)
(Optional)
Custom meta $key => $value pairs to use.

Default value: array()

{acontent3}

You must log in before being able to contribute a note or feedback.

62.50% (10) 次Baidu访问
6.25% (1) 次Google访问
31.25% (5) 次Sogou访问
  • 蜘蛛:Baidu,10次,更新时间:2019-05-20 20:05:23
  • 蜘蛛:Google,1次,更新时间:2019-04-21 14:07:44
  • 蜘蛛:Sogou,5次,更新时间:2019-05-18 14:03:46

参与评论