forked from jquery/jquery-wp-content
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
94 lines (69 loc) · 2.97 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
global $blog_id;
if ( 1 != $blog_id && false !== strpos( $_SERVER['PHP_SELF'], 'wp-admin/install.php' ) ) {
wp_redirect( 'http://' . DOMAIN_CURRENT_SITE . '/wp-admin/install.php' );
exit;
}
if ( ! isset( $_POST['weblog_title'] ) )
$_POST['weblog_title'] = 'jQuery';
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 );
}
function jquery_install_site( $site, $user ) {
$sites = jquery_sites();
$details = $sites[ $site ];
if ( strpos( $site, '/' ) ) {
list( $domain, $path ) = explode( '/', $site, 2 );
$path = '/' . trim( $path, '/' ) . '/';
} else {
$domain = $site;
$path = '/';
}
$default_options = jquery_default_site_options();
$default_options['admin_email'] = $user->user_email;
var_dump( $domain, $path, $site );
if ( 1 !== $details['blog_id'] ) {
$blog_id = insert_blog( JQUERY_STAGING_PREFIX . $domain, $path, 1 );
if ( $blog_id != $details['blog_id'] )
wp_die( "Something went very wrong when trying to install $domain as site $blog_id-{$details['blog_id']}. Find nacin." );
switch_to_blog( $blog_id );
install_blog( $blog_id, $details['options']['blogname'] );
add_user_to_blog( $blog_id, $user->ID, 'administrator' );
}
$options = array_merge( $default_options, $details['options'] );
foreach ( $options as $option => $value )
update_option( $option, $value );
flush_rewrite_rules();
restore_current_blog();
}