Changeset 43629 for trunk/src/wp-admin/includes/schema.php
- Timestamp:
- 09/05/2018 11:01:36 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r43628 r43629 1293 1293 $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared 1294 1294 } 1295 1296 /** 1297 * Creates WordPress site meta and sets the default values. 1298 * 1299 * @since 5.0.0 1300 * 1301 * @global wpdb $wpdb WordPress database abstraction object. 1302 * 1303 * @param int $site_id Site ID to populate meta for. 1304 * @param array $meta Optional. Custom meta $key => $value pairs to use. Default empty array. 1305 */ 1306 function populate_site_meta( $site_id, array $meta = array() ) { 1307 global $wpdb; 1308 1309 $site_id = (int) $site_id; 1310 1311 if ( ! is_site_meta_supported() ) { 1312 return; 1313 } 1314 1315 if ( empty( $meta ) ) { 1316 return; 1317 } 1318 1319 $insert = ''; 1320 foreach ( $meta as $meta_key => $meta_value ) { 1321 if ( is_array( $meta_value ) ) { 1322 $meta_value = serialize( $meta_value ); 1323 } 1324 if ( ! empty( $insert ) ) { 1325 $insert .= ', '; 1326 } 1327 $insert .= $wpdb->prepare( '( %d, %s, %s)', $site_id, $meta_key, $meta_value ); 1328 } 1329 1330 $wpdb->query( "INSERT INTO $wpdb->blogmeta ( blog_id, meta_key, meta_value ) VALUES " . $insert ); // phpcs:ignore WordPress.WP.PreparedSQL.NotPrepared 1331 1332 wp_cache_set( 'last_changed', microtime(), 'sites' ); 1333 }
Note: See TracChangeset
for help on using the changeset viewer.