Changeset 12756 for trunk/wp-admin/includes/schema.php
- Timestamp:
- 01/19/2010 12:04:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/schema.php
r12754 r12756 318 318 ); 319 319 320 // 3.0 multisite 321 if ( is_multisite() ) { 322 $options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name ); 323 $options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; 324 } 325 320 326 // Set autoload to no for these options 321 327 $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); … … 607 613 } 608 614 615 /** 616 * populate network settings 617 * 618 * @since 3.0 619 * 620 * @param int $network_id id of network to populate 621 */ 622 function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $vhost = 'no' ) { 623 global $wpdb, $current_site, $wp_version, $wp_db_version, $wp_rewrite; 624 625 //@todo: turn these checks into returned messages 626 if( $domain == '' ) 627 die( 'You must provide a domain name!' ); 628 if( $site_name == '' ) 629 die( 'You must provide a site name!' ); 630 631 // check for network collision 632 $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id ) ); 633 if( $existing_network == $network_id ) 634 die( 'That network already exists!' ); 635 636 $site_user = get_user_by_email( $email ); 637 if( !$site_user ) 638 die( 'You must provide an email address!' ); 639 // set up site tables 640 $template = get_option( 'template' ); 641 $stylesheet = get_option( 'stylesheet' ); 642 if ( $template != $stylesheet ) { 643 $allowed_themes = array( $template, $stylesheet ); 644 } else { 645 $allowed_themes = array( $stylesheet ); 646 } 647 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_name', %s)", $network_id, $site_name ) ); 648 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_email', %s)", $network_id, $site_user->user_email ) ); 649 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_user_id', %d)", $network_id, $site_user->ID ) ); 650 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'registration', 'none')", $network_id ) ); 651 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( %d, %s, %s )", $network_id, $domain, $path ) ); 652 if ( !is_multisite() ) { 653 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" ); 654 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" ); 655 } 656 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )", $network_id ) ); 657 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'blog_upload_space', '10' )", $network_id ) ); 658 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'fileupload_maxk', '1500' )", $network_id ) ); 659 if ( !is_multisite() ) { 660 $site_admins = array( $site_user->user_login ); 661 $users = get_users_of_blog(); 662 if ( $users ) { 663 foreach ( $users as $user ) { 664 if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) ) { 665 $site_admins[] = $user->user_login; 666 } 667 } 668 } 669 } else { 670 $site_admins = get_site_option( 'site_admins' ); 671 } 672 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_admins', '" . serialize( $site_admins ) . "' )", $network_id ) ); 673 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'allowedthemes', '" . serialize( $allowed_themes ) . "' )", $network_id ) ); 674 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'illegal_names', '" . serialize( array( "www", "web", "root", "admin", "main", "invite", "administrator" ) ) . "' )", $network_id ) ); 675 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'wpmu_upgrade_site', '{$wp_db_version}')", $network_id ) ); 676 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'welcome_email', 'Dear User, 677 678 Your new SITE_NAME blog has been successfully set up at: 679 BLOG_URL 680 681 You can log in to the administrator account with the following information: 682 Username: USERNAME 683 Password: PASSWORD 684 Login Here: BLOG_URLwp-login.php 685 686 We hope you enjoy your new blog. 687 Thanks! 688 689 --The Team @ SITE_NAME')", $network_id ) ); 690 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )", $network_id ) ); 691 $weblog_title = stripslashes( $_POST[ 'weblog_title' ] ); 692 693 $current_site->domain = $domain; 694 $current_site->path = $base; 695 $current_site->site_name = ucfirst( $domain ); 696 697 if ( !is_multisite() ) { 698 $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->blogs} (site_id, domain, path) VALUES (%s, %s, %s)", $network_id, $domain, $path ) ); 699 update_usermeta( $site_user->ID, 'source_domain', $domain ); 700 update_usermeta( $site_user->ID, 'primary_blog', 1 ); 701 } 702 703 if( $vhost == 'yes' ) { 704 update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); 705 } else { 706 update_option( 'permalink_structure', '/blog/%year%/%monthnum%/%day%/%postname%/'); 707 } 708 $wp_rewrite->flush_rules(); 709 710 if ( $vhost == 'yes' ) { 711 $vhost_ok = false; 712 $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! 713 $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); 714 if( is_object( $page ) && is_wp_error( $page ) ) { 715 foreach ( $page->get_error_messages() as $err ) 716 $errstr = $err; 717 } elseif( $page[ 'response' ][ 'code' ] == 200 ) { 718 $vhost_ok = true; 719 } 720 if( !$vhost_ok ) { 721 $msg = "<h2>Warning! Wildcard DNS may not be configured correctly!</h2>"; 722 $msg .= "<p>To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:<br /> <strong>$errstr</strong></p><p>From the README.txt:</p>"; 723 $msg .= "<p><blockquote> If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records.<br /> 724 This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool. Matt has a more detailed <a href='http://ma.tt/2003/10/10/wildcard-dns-and-sub-domains/'>explanation</a> on his blog. If you still have problems, these <a href='http://mu.wordpress.org/forums/tags/wildcard'>forum messages</a> may help.</blockquote></p>"; 725 $msg .= "<p>You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.</p>"; 726 } 727 } 728 return $msg; 729 } 609 730 ?>
Note: See TracChangeset
for help on using the changeset viewer.