web/wp-admin/includes/upgrade.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
   120 	}
   120 	}
   121 
   121 
   122 	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
   122 	$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
   123 	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
   123 	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
   124 	$cat_tt_id = $wpdb->insert_id;
   124 	$cat_tt_id = $wpdb->insert_id;
   125 
       
   126 	// Default link category
       
   127 	$cat_name = __('Blogroll');
       
   128 	/* translators: Default link category slug */
       
   129 	$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
       
   130 
       
   131 	if ( global_terms_enabled() ) {
       
   132 		$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
       
   133 		if ( $blogroll_id == null ) {
       
   134 			$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
       
   135 			$blogroll_id = $wpdb->insert_id;
       
   136 		}
       
   137 		update_option('default_link_category', $blogroll_id);
       
   138 	} else {
       
   139 		$blogroll_id = 2;
       
   140 	}
       
   141 
       
   142 	$wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
       
   143 	$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
       
   144 	$blogroll_tt_id = $wpdb->insert_id;
       
   145 
       
   146 	// Now drop in some default links
       
   147 	$default_links = array();
       
   148 	$default_links[] = array(	'link_url' => __( 'http://codex.wordpress.org/' ),
       
   149 								'link_name' => __( 'Documentation' ),
       
   150 								'link_rss' => '',
       
   151 								'link_notes' => '');
       
   152 
       
   153 	$default_links[] = array(	'link_url' => __( 'http://wordpress.org/news/' ),
       
   154 								'link_name' => __( 'WordPress Blog' ),
       
   155 								'link_rss' => __( 'http://wordpress.org/news/feed/' ),
       
   156 								'link_notes' => '');
       
   157 
       
   158 	$default_links[] = array(	'link_url' => __( 'http://wordpress.org/support/' ),
       
   159 								'link_name' => _x( 'Support Forums', 'default link' ),
       
   160 								'link_rss' => '',
       
   161 								'link_notes' =>'');
       
   162 
       
   163 	$default_links[] = array(	'link_url' => 'http://wordpress.org/extend/plugins/',
       
   164 								'link_name' => _x( 'Plugins', 'Default link to wordpress.org/extend/plugins/' ),
       
   165 								'link_rss' => '',
       
   166 								'link_notes' =>'');
       
   167 
       
   168 	$default_links[] = array(	'link_url' => 'http://wordpress.org/extend/themes/',
       
   169 								'link_name' => _x( 'Themes', 'Default link to wordpress.org/extend/themes/' ),
       
   170 								'link_rss' => '',
       
   171 								'link_notes' =>'');
       
   172 
       
   173 	$default_links[] = array(	'link_url' => __( 'http://wordpress.org/support/forum/requests-and-feedback' ),
       
   174 								'link_name' => __( 'Feedback' ),
       
   175 								'link_rss' => '',
       
   176 								'link_notes' =>'');
       
   177 
       
   178 	$default_links[] = array(	'link_url' => __( 'http://planet.wordpress.org/' ),
       
   179 								'link_name' => __( 'WordPress Planet' ),
       
   180 								'link_rss' => '',
       
   181 								'link_notes' =>'');
       
   182 
       
   183 	foreach ( $default_links as $link ) {
       
   184 		$wpdb->insert( $wpdb->links, $link);
       
   185 		$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );
       
   186 	}
       
   187 
   125 
   188 	// First post
   126 	// First post
   189 	$now = date('Y-m-d H:i:s');
   127 	$now = date('Y-m-d H:i:s');
   190 	$now_gmt = gmdate('Y-m-d H:i:s');
   128 	$now_gmt = gmdate('Y-m-d H:i:s');
   191 	$first_post_guid = get_option('home') . '/?p=1';
   129 	$first_post_guid = get_option('home') . '/?p=1';
   222 	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
   160 	$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
   223 
   161 
   224 	// Default comment
   162 	// Default comment
   225 	$first_comment_author = __('Mr WordPress');
   163 	$first_comment_author = __('Mr WordPress');
   226 	$first_comment_url = 'http://wordpress.org/';
   164 	$first_comment_url = 'http://wordpress.org/';
   227 	$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
   165 	$first_comment = __('Hi, this is a comment.
       
   166 To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
   228 	if ( is_multisite() ) {
   167 	if ( is_multisite() ) {
   229 		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
   168 		$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
   230 		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
   169 		$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
   231 		$first_comment = get_site_option( 'first_comment', $first_comment );
   170 		$first_comment = get_site_option( 'first_comment', $first_comment );
   232 	}
   171 	}
   245 
   184 
   246 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
   185 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
   247 
   186 
   248 ...or something like this:
   187 ...or something like this:
   249 
   188 
   250 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
   189 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
   251 
   190 
   252 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
   191 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
   253 	if ( is_multisite() )
   192 	if ( is_multisite() )
   254 		$first_page = get_site_option( 'first_page', $first_page );
   193 		$first_page = get_site_option( 'first_page', $first_page );
   255 	$first_post_guid = get_option('home') . '/?page_id=2';
   194 	$first_post_guid = get_option('home') . '/?page_id=2';
   277 	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
   216 	update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
   278 	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
   217 	update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
   279 	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
   218 	update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
   280 	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
   219 	update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
   281 	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
   220 	update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
   282 	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'sidebar-2' => array ( ), 'sidebar-3' => array ( ), 'sidebar-4' => array ( ), 'sidebar-5' => array ( ), 'array_version' => 3 ) );
   221 	update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'sidebar-2' => array ( ), 'sidebar-3' => array ( ), 'array_version' => 3 ) );
   283 
   222 
   284 	if ( ! is_multisite() )
   223 	if ( ! is_multisite() )
   285 		update_user_meta( $user_id, 'show_welcome_panel', 1 );
   224 		update_user_meta( $user_id, 'show_welcome_panel', 1 );
   286 	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
   225 	elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
   287 		update_user_meta( $user_id, 'show_welcome_panel', 2 );
   226 		update_user_meta( $user_id, 'show_welcome_panel', 2 );
   317  * @param string $blog_url Blog url.
   256  * @param string $blog_url Blog url.
   318  * @param int $user_id User ID.
   257  * @param int $user_id User ID.
   319  * @param string $password User's Password.
   258  * @param string $password User's Password.
   320  */
   259  */
   321 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
   260 function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
   322 	$user = new WP_User($user_id);
   261 	$user = new WP_User( $user_id );
   323 	$email = $user->user_email;
   262 	$email = $user->user_email;
   324 	$name = $user->user_login;
   263 	$name = $user->user_login;
   325 	$message = sprintf(__("Your new WordPress site has been successfully set up at:
   264 	$message = sprintf(__("Your new WordPress site has been successfully set up at:
   326 
   265 
   327 %1\$s
   266 %1\$s
   457 	if ( $wp_current_db_version < 19389 )
   396 	if ( $wp_current_db_version < 19389 )
   458 		upgrade_330();
   397 		upgrade_330();
   459 
   398 
   460 	if ( $wp_current_db_version < 20080 )
   399 	if ( $wp_current_db_version < 20080 )
   461 		upgrade_340();
   400 		upgrade_340();
       
   401 
       
   402 	if ( $wp_current_db_version < 22422 )
       
   403 		upgrade_350();
       
   404 
       
   405 	maybe_disable_link_manager();
   462 
   406 
   463 	maybe_disable_automattic_widgets();
   407 	maybe_disable_automattic_widgets();
   464 
   408 
   465 	update_option( 'db_version', $wp_db_version );
   409 	update_option( 'db_version', $wp_db_version );
   466 	update_option( 'db_upgraded', true );
   410 	update_option( 'db_upgraded', true );
   565 	$all_options = get_alloptions_110();
   509 	$all_options = get_alloptions_110();
   566 
   510 
   567 	$time_difference = $all_options->time_difference;
   511 	$time_difference = $all_options->time_difference;
   568 
   512 
   569 		$server_time = time()+date('Z');
   513 		$server_time = time()+date('Z');
   570 	$weblogger_time = $server_time + $time_difference*3600;
   514 	$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
   571 	$gmt_time = time();
   515 	$gmt_time = time();
   572 
   516 
   573 	$diff_gmt_server = ($gmt_time - $server_time) / 3600;
   517 	$diff_gmt_server = ($gmt_time - $server_time) / HOUR_IN_SECONDS;
   574 	$diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
   518 	$diff_weblogger_server = ($weblogger_time - $server_time) / HOUR_IN_SECONDS;
   575 	$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
   519 	$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
   576 	$gmt_offset = -$diff_gmt_weblogger;
   520 	$gmt_offset = -$diff_gmt_weblogger;
   577 
   521 
   578 	// Add a gmt_offset option, with value $gmt_offset
   522 	// Add a gmt_offset option, with value $gmt_offset
   579 	add_option('gmt_offset', $gmt_offset);
   523 	add_option('gmt_offset', $gmt_offset);
  1048 function upgrade_260() {
   992 function upgrade_260() {
  1049 	global $wp_current_db_version;
   993 	global $wp_current_db_version;
  1050 
   994 
  1051 	if ( $wp_current_db_version < 8000 )
   995 	if ( $wp_current_db_version < 8000 )
  1052 		populate_roles_260();
   996 		populate_roles_260();
  1053 
       
  1054 	if ( $wp_current_db_version < 8201 ) {
       
  1055 		update_option('enable_app', 1);
       
  1056 		update_option('enable_xmlrpc', 1);
       
  1057 	}
       
  1058 }
   997 }
  1059 
   998 
  1060 /**
   999 /**
  1061  * Execute changes made in WordPress 2.7.
  1000  * Execute changes made in WordPress 2.7.
  1062  *
  1001  *
  1241 		}
  1180 		}
  1242 	}
  1181 	}
  1243 }
  1182 }
  1244 
  1183 
  1245 /**
  1184 /**
       
  1185  * Execute changes made in WordPress 3.5.
       
  1186  *
       
  1187  * @since 3.5.0
       
  1188  */
       
  1189 function upgrade_350() {
       
  1190 	global $wp_current_db_version, $wpdb;
       
  1191 
       
  1192 	if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
       
  1193 		update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
       
  1194 
       
  1195 	if ( $wp_current_db_version < 21811 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
       
  1196 		$meta_keys = array();
       
  1197 		foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
       
  1198 			if ( false !== strpos( $name, '-' ) )
       
  1199 			$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
       
  1200 		}
       
  1201 		if ( $meta_keys ) {
       
  1202 			$meta_keys = implode( "', '", $meta_keys );
       
  1203 			$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
       
  1204 		}
       
  1205 	}
       
  1206 
       
  1207 	if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
       
  1208 		wp_delete_term( $term->term_id, 'post_format' );
       
  1209 }
       
  1210 
       
  1211 /**
  1246  * Execute network level changes
  1212  * Execute network level changes
  1247  *
  1213  *
  1248  * @since 3.0.0
  1214  * @since 3.0.0
  1249  */
  1215  */
  1250 function upgrade_network() {
  1216 function upgrade_network() {
  1305 			}
  1271 			}
  1306 			update_site_option( 'allowedthemes', $converted );
  1272 			update_site_option( 'allowedthemes', $converted );
  1307 			delete_site_option( 'allowed_themes' );
  1273 			delete_site_option( 'allowed_themes' );
  1308 		}
  1274 		}
  1309 	}
  1275 	}
       
  1276 
       
  1277 	// 3.5
       
  1278 	if ( $wp_current_db_version < 21823 )
       
  1279 		update_site_option( 'ms_files_rewriting', '1' );
  1310 }
  1280 }
  1311 
  1281 
  1312 // The functions we use to actually do stuff
  1282 // The functions we use to actually do stuff
  1313 
  1283 
  1314 // General
  1284 // General
  1952 	if ( is_wp_error( $result ) )
  1922 	if ( is_wp_error( $result ) )
  1953 		die( $result->get_error_message() );
  1923 		die( $result->get_error_message() );
  1954 }
  1924 }
  1955 
  1925 
  1956 /**
  1926 /**
  1957  * {@internal Missing Short Description}}
  1927  * Disables the Automattic widgets plugin, which was merged into core.
  1958  *
       
  1959  * {@internal Missing Long Description}}
       
  1960  *
  1928  *
  1961  * @since 2.2.0
  1929  * @since 2.2.0
  1962  */
  1930  */
  1963 function maybe_disable_automattic_widgets() {
  1931 function maybe_disable_automattic_widgets() {
  1964 	$plugins = __get_option( 'active_plugins' );
  1932 	$plugins = __get_option( 'active_plugins' );
  1968 			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
  1936 			array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
  1969 			update_option( 'active_plugins', $plugins );
  1937 			update_option( 'active_plugins', $plugins );
  1970 			break;
  1938 			break;
  1971 		}
  1939 		}
  1972 	}
  1940 	}
       
  1941 }
       
  1942 
       
  1943 /**
       
  1944  * Disables the Link Manager on upgrade, if at the time of upgrade, no links exist in the DB.
       
  1945  *
       
  1946  * @since 3.5.0
       
  1947  */
       
  1948 function maybe_disable_link_manager() {
       
  1949 	global $wp_current_db_version, $wpdb;
       
  1950 
       
  1951 	if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
       
  1952 		update_option( 'link_manager_enabled', 0 );
  1973 }
  1953 }
  1974 
  1954 
  1975 /**
  1955 /**
  1976  * Runs before the schema is upgraded.
  1956  * Runs before the schema is upgraded.
  1977  *
  1957  *