创建一个空博客。

原型

create_empty_blog( string $domain, string $path, string $weblog_title, int $site_id = 1 )

参数

$domain (string) (Required) 新博客的域名。

$path (string) (Required) 新博客的路径。

$weblog_title (string) (Required) 新博客的标题。

$site_id (int) (Optional)  默认为1。

返回值

(string|int)  新创建的博客的ID

源文件

路径:wp-includes/ms-deprecated.php

<?php
...
function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
	_deprecated_function( __FUNCTION__, '4.4.0' );
	if ( empty($path) )
		$path = '/';
	// Check if the domain has been used already. We should return an error message.
	if ( domain_exists($domain, $path, $site_id) )
		return __( '<strong>ERROR</strong>: Site URL already taken.' );
	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.
	// Need to get blog_id from wp_blogs, and create new table names.
	// Must restore table names at the end of function.
	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
		return __( '<strong>ERROR</strong>: problem creating site entry.' );
	switch_to_blog($blog_id);
	install_blog($blog_id);
	restore_current_blog();
	return $blog_id;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/create_empty_blog/