install_blog()
最后更新于:2021-11-27 07:02:27
install_blog( int$blog_id, string$blog_title=”)Install an empty blog.
参数
- $blog_id
-
(int) (Required) The value returned by gc_insert_site().
- $blog_title
-
(string) (Optional) The title of the new site.
Default value: ”
源文件
文件: gc-includes/ms-deprecated.php
function install_blog( $blog_id, $blog_title = '' ) {
global $gcdb, $gc_roles;
_deprecated_function( __FUNCTION__, '5.1.0' );
// Cast for security.
$blog_id = (int) $blog_id;
require_once ABSPATH . 'gc-admin/includes/upgrade.php';
$suppress = $gcdb->suppress_errors();
if ( $gcdb->get_results( "DESCRIBE {$gcdb->posts}" ) ) {
die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed GeChiUI. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
}
$gcdb->suppress_errors( $suppress );
$url = get_blogaddress_by_id( $blog_id );
// Set everything up.
make_db_current_silent( 'blog' );
populate_options();
populate_roles();
// populate_roles() clears previous role definitions so we start over.
$gc_roles = new GC_Roles();
$siteurl = $home = untrailingslashit( $url );
if ( ! is_subdomain_install() ) {
if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
$siteurl = set_url_scheme( $siteurl, 'https' );
}
if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
$home = set_url_scheme( $home, 'https' );
}
}
update_option( 'siteurl', $siteurl );
update_option( 'home', $home );
if ( get_site_option( 'ms_files_rewriting' ) ) {
update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
} else {
update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
}
update_option( 'blogname', gc_unslash( $blog_title ) );
update_option( 'admin_email', '' );
// Remove all permissions.
$table_prefix = $gcdb->get_blog_prefix();
delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // Delete all.
delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all.
}