Definition:
function install_blog($blog_id, $blog_title = '') {}
Install an empty blog.
Creates the new blog tables and options. If calling this function directly, be sure to use switch_to_blog() first, so that $wpdb points to the new blog.
Parameters
- int $blog_id: The value returned by insert_blog().
- string $blog_title: The title of the new site.
Source code
function install_blog($blog_id, $blog_title = '') {
global $wpdb, $table_prefix, $wp_roles;
$wpdb->suppress_errors();
// Cast for security
$blog_id = (int) $blog_id;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
die(__('<h1>Already Installed</h1><p>You appear to have already installed WordPress. To reinstall please clear your old database tables first.</p>') . '</body></html>');
$wpdb->suppress_errors(false);
$url = get_blogaddress_by_id($blog_id);
// Set everything up
make_db_current_silent( 'blog' );
populate_options();
populate_roles();
$wp_roles->_init();
// fix url.
update_option('siteurl', $url);
update_option('home', $url);
update_option('fileupload_url', $url . "files" );
update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files");
update_option('blogname', stripslashes( $blog_title ) );
update_option('admin_email', '');
$wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
// remove all perms
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'capabilities') );
$wpdb->suppress_errors( false );
}
2023

February 12, 2011 


No comments yet... Be the first to leave a reply!