insert_blog( string $domain, string $path, int $network_id )
Store basic site info in the blogs table.
Description
This function creates a row in the wp_blogs table and returns the new blog’s ID. It is the first step in creating a new blog.
Parameters
- $domain
-
(Required) The domain of the new site.
- $path
-
(Required) The path of the new site.
- $network_id
-
(Required) Unless you're running a multi-network installation, be sure to set this value to 1.
Return
(int|false) The ID of the new row
Source
File: wp-includes/ms-functions.php
function insert_blog($domain, $path, $network_id) {
global $wpdb;
$path = trailingslashit($path);
$network_id = (int) $network_id;
$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
if ( ! $result )
return false;
$blog_id = $wpdb->insert_id;
clean_blog_cache( $blog_id );
wp_maybe_update_network_site_counts( $network_id );
return $blog_id;
}
Changelog
Version | Description |
---|---|
WP-MU | Introduced. (3.0.0) |