function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) { global $wpdb; $base = '/'; $domain = JQUERY_STAGING_PREFIX . 'jquery.com'; wp_check_mysql_version(); wp_cache_flush(); make_db_current_silent(); populate_options(); populate_roles(); $user_id = wp_create_user( $user_name, trim( $user_password ), $user_email ); $user = new WP_User( $user_id ); $user->set_role( 'administrator' ); $guess_url = wp_guess_url(); foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) $wpdb->$table = $prefixed_table; install_network(); populate_network( 1, $domain, $user_email, 'jQuery Network', $base, false ); update_site_option( 'site_admins', array( $user->user_login ) ); update_site_option( 'allowedthemes', array() ); $wpdb->insert( $wpdb->blogs, array( 'site_id' => 1, 'domain' => $domain, 'path' => $base, 'registered' => current_time( 'mysql' ) ) ); $blog_id = $wpdb->insert_id; update_user_meta( $user_id, 'source_domain', $domain ); update_user_meta( $user_id, 'primary_blog', $blog_id ); if ( !$upload_path = get_option( 'upload_path' ) ) { $upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads'; update_option( 'upload_path', $upload_path ); } update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path ); foreach ( jquery_sites() as $site => $details ) jquery_install_site( $site, $user ); wp_new_blog_notification( $blog_title, $guess_url, $user_id, $message = __( 'The password you chose during the install.' ) ); wp_cache_flush(); return array( 'url' => $guess_url, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message ); }
wp_redirect( 'http://' . DOMAIN_CURRENT_SITE . '/wp-admin/install.php' ); die(); } // Otherwise, we have a working network, but have a new site to install. Do that now. define( 'WP_INSTALLING', true ); add_action( 'init', function() use ( $blog_id ) { global $wpdb; $wpdb->set_blog_id( $blog_id ); if ( is_super_admin() ) { $super_admin = wp_get_current_user(); } else { $super_admins = get_super_admins(); $super_admin = get_user_by( 'login', reset( $super_admins ) ); } require ABSPATH . 'wp-admin/includes/upgrade.php'; $sites = jquery_sites(); $site = str_replace( JQUERY_STAGING_PREFIX, '', $_SERVER['HTTP_HOST'] ); if ( ! empty( $sites[ $site ]['subsites'] ) ) { list( $first_path_segment ) = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ), 2 ); if ( $first_path_segment && isset( $sites[ $site . '/' . $first_path_segment ] ) ) $site .= '/' . $first_path_segment; } jquery_install_site( $site, $super_admin ); wp_safe_redirect( 'http://' . JQUERY_STAGING_PREFIX . $site ); exit; } ); } } }