Changeset 3670 for trunk/wp-admin/upgrade-functions.php
- Timestamp:
- 03/31/2006 08:07:39 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/upgrade-functions.php
r3635 r3670 1 1 <?php 2 2 3 if ( file_exists(ABSPATH . 'wp-content/install.php') ) 4 require (ABSPATH . 'wp-content/install.php'); 3 5 require_once(ABSPATH . '/wp-admin/admin-functions.php'); 4 6 require_once(ABSPATH . '/wp-admin/admin-db.php'); 5 7 require_once(ABSPATH . '/wp-admin/upgrade-schema.php'); 8 require_once(ABSPATH . '/wp-includes/registration-functions.php'); 9 10 if ( !function_exists('wp_install') ) : 11 function wp_install($blog_title, $user_name, $user_email, $public, $meta='') { 12 global $wp_rewrite; 13 14 wp_cache_flush(); 15 make_db_current_silent(); 16 populate_options(); 17 populate_roles(); 18 19 update_option('blogname', $blog_title); 20 update_option('admin_email', $user_email); 21 update_option('blog_public', $public); 22 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 23 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 24 update_option('siteurl', $guessurl); 25 26 // If not a public blog, don't ping. 27 if ( ! $public ) 28 update_option('default_pingback_flag', 0); 29 30 // Create default user. 31 $random_password = substr(md5(uniqid(microtime())), 0, 6); 32 $user_id = wp_create_user($user_name, $random_password, $user_email); 33 $user = new WP_User($user_id); 34 $user->set_role('administrator'); 35 36 wp_install_defaults($user_id); 37 38 $wp_rewrite->flush_rules(); 39 40 wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password); 41 42 wp_cache_flush(); 43 44 return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password); 45 } 46 endif; 47 48 if ( !function_exists('wp_install_defaults') ) : 49 function wp_install_defaults($user_id) { 50 global $wpdb; 51 52 // Default category 53 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')"); 54 55 // Default link category 56 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')"); 57 58 // Now drop in some default links 59 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');"); 60 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" ); 61 62 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');"); 63 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" ); 64 65 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');"); 66 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" ); 67 68 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');"); 69 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" ); 70 71 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');"); 72 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" ); 73 74 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');"); 75 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" ); 76 77 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');"); 78 $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" ); 79 80 // First post 81 $now = date('Y-m-d H:i:s'); 82 $now_gmt = gmdate('Y-m-d H:i:s'); 83 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')"); 84 85 $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" ); 86 87 // Default comment 88 $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')"); 89 90 // First Page 91 92 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')"); 93 } 94 endif; 95 96 if ( !function_exists('wp_new_blog_notification') ) : 97 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { 98 $user = new WP_User($user_id); 99 $email = $user->user_email; 100 $name = $user->user_login; 101 $message_headers = 'From: ' . $blog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>'; 102 $message = sprintf(__("Your new WordPress blog has been successfully set up at: 103 104 %1\$s 105 106 You can log in to the administrator account with the following information: 107 108 Username: %2\$s 109 Password: %3\$s 110 111 We hope you enjoy your new weblog. Thanks! 112 113 --The WordPress Team 114 http://wordpress.org/ 115 "), $blog_url, $name, $password); 116 117 @wp_mail($email, __('New WordPress Blog'), $message, $message_headers); 118 } 119 endif; 120 121 if ( !function_exists('wp_upgrade') ) : 122 function wp_upgrade() { 123 global $wp_current_db_version, $wp_db_version; 124 125 $wp_current_db_version = __get_option('db_version'); 126 127 // We are up-to-date. Nothing to do. 128 if ( $wp_db_version == $wp_current_db_version ) 129 return; 130 131 wp_cache_flush(); 132 make_db_current_silent(); 133 upgrade_all(); 134 wp_cache_flush(); 135 } 136 endif; 137 6 138 // Functions to be called in install and upgrade scripts 7 139 function upgrade_all() {
Note: See TracChangeset
for help on using the changeset viewer.