insert_blog

函式
insert_blog ( $domain, $path, $site_id )
引數
  • (string) $domain The domain of the new site.
    Required:
  • (string) $path The path of the new site.
    Required:
  • (int) $site_id Unless you're running a multi-network install, be sure to set this value to 1.
    Required:
返回值
  • (int|false) The ID of the new row
相關
  • wp_insert_site()
定義位置
相關方法
install_blogadd_user_to_blogadd_new_user_to_blogwp_insert_postwp_insert_link
引入
-
棄用
5.1.0

insert_blog: 這個函式用來在一個WordPress多站點安裝中建立一個新的站點。它接受一個站點詳細資訊的陣列,並返回新建立站點的ID。

在blogs表中儲存網站的基本資訊。

這個函式在wp_blogs表中建立一條記錄,並返回新部落格的ID: 這是建立一個新部落格的第一步。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >