insert_blog

The timeline below displays how wordpress function insert_blog has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU (3.0.0)
 * @deprecated 5.1.0 Use wp_insert_site()
 * @see wp_insert_site()
 *
 * @param string $domain  The domain of the new site.
 * @param string $path    The path of the new site.
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int|false The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    _deprecated_function(__FUNCTION__, '5.1.0', 'wp_insert_site()');
    $data = array('domain' => $domain, 'path' => $path, 'site_id' => $site_id);
    $site_id = wp_insert_site($data);
    if (is_wp_error($site_id)) {
        return false;
    }
    clean_blog_cache($site_id);
    return $site_id;
}

WordPress Version: 5.1

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU (3.0.0)
 * @deprecated 5.1.0 Use `wp_insert_site()`
 * @see wp_insert_site()
 *
 * @param string $domain  The domain of the new site.
 * @param string $path    The path of the new site.
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int|false The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    _deprecated_function(__FUNCTION__, '5.1.0', 'wp_insert_site()');
    $data = array('domain' => $domain, 'path' => $path, 'site_id' => $site_id);
    $site_id = wp_insert_site($data);
    if (is_wp_error($site_id)) {
        return false;
    }
    clean_blog_cache($site_id);
    return $site_id;
}

WordPress Version: 4.9

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $domain     The domain of the new site.
 * @param string $path       The path of the new site.
 * @param int    $network_id 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
 */
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;
}

WordPress Version: 4.8

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $domain  The domain of the new site.
 * @param string $path    The path of the new site.
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int|false The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    global $wpdb;
    $path = trailingslashit($path);
    $site_id = (int) $site_id;
    $result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
    if (!$result) {
        return false;
    }
    $blog_id = $wpdb->insert_id;
    refresh_blog_details($blog_id);
    wp_maybe_update_network_site_counts($site_id);
    return $blog_id;
}

WordPress Version: 4.4

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param string $domain  The domain of the new site.
 * @param string $path    The path of the new site.
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int|false The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    global $wpdb;
    $path = trailingslashit($path);
    $site_id = (int) $site_id;
    $result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
    if (!$result) {
        return false;
    }
    $blog_id = $wpdb->insert_id;
    refresh_blog_details($blog_id);
    wp_maybe_update_network_site_counts();
    return $blog_id;
}

WordPress Version: 4.3

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU
 *
 * @global wpdb $wpdb
 *
 * @param string $domain  The domain of the new site.
 * @param string $path    The path of the new site.
 * @param int    $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int|false The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    global $wpdb;
    $path = trailingslashit($path);
    $site_id = (int) $site_id;
    $result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
    if (!$result) {
        return false;
    }
    $blog_id = $wpdb->insert_id;
    refresh_blog_details($blog_id);
    wp_maybe_update_network_site_counts();
    return $blog_id;
}

WordPress Version: 3.7

/**
 * Store basic site info in the blogs table.
 *
 * 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.
 *
 * @since MU
 *
 * @param string $domain The domain of the new site.
 * @param string $path The path of the new site.
 * @param int $site_id Unless you're running a multi-network install, be sure to set this value to 1.
 * @return int The ID of the new row
 */
function insert_blog($domain, $path, $site_id)
{
    global $wpdb;
    $path = trailingslashit($path);
    $site_id = (int) $site_id;
    $result = $wpdb->insert($wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')));
    if (!$result) {
        return false;
    }
    $blog_id = $wpdb->insert_id;
    refresh_blog_details($blog_id);
    wp_maybe_update_network_site_counts();
    return $blog_id;
}