Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




install_blog [ WordPress Function ]

install_blog ( $blog_id, $blog_title = '' )
Parameters:
  • (int) $blog_id The value returned by insert_blog().
  • (string) $blog_title The title of the new site.
Uses:
Defined at:



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.

Source


<?php
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->delete$wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) );

    
$wpdb->delete$wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );

    
$wpdb->suppress_errorsfalse );
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics