create_empty_blog()

最后更新于:2021-11-25 22:29:08

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

Create an empty blog.

参数

$domain

(string) (Required) The new blog’s domain.

$path

(string) (Required) The new blog’s path.

$weblog_title

(string) (Required) The new blog’s title.

$site_id

(int) (Optional) Defaults to 1.

Default value: 1

响应

(string|int) The ID of the newly created blog

源文件

文件: gc-includes/ms-deprecated.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 you&#8217;ve entered is already taken.' );

	/*
	 * Need to back up gcdb table names, and create a new gc_blogs entry for new blog.
	 * Need to get blog_id from gc_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>: There was a problem creating site entry.' );

	switch_to_blog($blog_id);
	install_blog($blog_id);
	restore_current_blog();

	return $blog_id;
}