web/wp-admin/includes/schema.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    15  * The database character collate.
    15  * The database character collate.
    16  * @var string
    16  * @var string
    17  * @global string
    17  * @global string
    18  * @name $charset_collate
    18  * @name $charset_collate
    19  */
    19  */
    20 $charset_collate = '';
    20 $charset_collate = $wpdb->get_charset_collate();
    21 
       
    22 if ( ! empty( $wpdb->charset ) )
       
    23 	$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
       
    24 if ( ! empty( $wpdb->collate ) )
       
    25 	$charset_collate .= " COLLATE $wpdb->collate";
       
    26 
    21 
    27 /**
    22 /**
    28  * Retrieve the SQL for creating database tables.
    23  * Retrieve the SQL for creating database tables.
    29  *
    24  *
    30  * @since 3.3.0
    25  * @since 3.3.0
   380 	'mailserver_port' => 110,
   375 	'mailserver_port' => 110,
   381 	'default_category' => 1,
   376 	'default_category' => 1,
   382 	'default_comment_status' => 'open',
   377 	'default_comment_status' => 'open',
   383 	'default_ping_status' => 'open',
   378 	'default_ping_status' => 'open',
   384 	'default_pingback_flag' => 1,
   379 	'default_pingback_flag' => 1,
   385 	'default_post_edit_rows' => 20,
       
   386 	'posts_per_page' => 10,
   380 	'posts_per_page' => 10,
   387 	/* translators: default date format, see http://php.net/date */
   381 	/* translators: default date format, see http://php.net/date */
   388 	'date_format' => __('F j, Y'),
   382 	'date_format' => __('F j, Y'),
   389 	/* translators: default time format, see http://php.net/date */
   383 	/* translators: default time format, see http://php.net/date */
   390 	'time_format' => __('g:i a'),
   384 	'time_format' => __('g:i a'),
   447 	'medium_size_w' => 300,
   441 	'medium_size_w' => 300,
   448 	'medium_size_h' => 300,
   442 	'medium_size_h' => 300,
   449 
   443 
   450 	// 2.6
   444 	// 2.6
   451 	'avatar_default' => 'mystery',
   445 	'avatar_default' => 'mystery',
   452 	'enable_app' => 0,
       
   453 	'enable_xmlrpc' => 0,
       
   454 
   446 
   455 	// 2.7
   447 	// 2.7
   456 	'large_size_w' => 1024,
   448 	'large_size_w' => 1024,
   457 	'large_size_h' => 1024,
   449 	'large_size_h' => 1024,
   458 	'image_default_link_type' => 'file',
   450 	'image_default_link_type' => 'file',
   473 	'uninstall_plugins' => array(),
   465 	'uninstall_plugins' => array(),
   474 
   466 
   475 	// 2.8
   467 	// 2.8
   476 	'timezone_string' => $timezone_string,
   468 	'timezone_string' => $timezone_string,
   477 
   469 
   478 	// 2.9
       
   479 	'embed_autourls' => 1,
       
   480 	'embed_size_w' => '',
       
   481 	'embed_size_h' => 600,
       
   482 
       
   483 	// 3.0
   470 	// 3.0
   484 	'page_for_posts' => 0,
   471 	'page_for_posts' => 0,
   485 	'page_on_front' => 0,
   472 	'page_on_front' => 0,
   486 
   473 
   487 	// 3.1
   474 	// 3.1
   488 	'default_post_format' => 0,
   475 	'default_post_format' => 0,
       
   476 
       
   477 	// 3.5
       
   478 	'link_manager_enabled' => 0,
   489 	);
   479 	);
   490 
   480 
   491 	// 3.3
   481 	// 3.3
   492 	if ( ! is_multisite() ) {
   482 	if ( ! is_multisite() ) {
   493 		$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
   483 		$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
   529 
   519 
   530 	// in case it is set, but blank, update "home"
   520 	// in case it is set, but blank, update "home"
   531 	if ( !__get_option('home') ) update_option('home', $guessurl);
   521 	if ( !__get_option('home') ) update_option('home', $guessurl);
   532 
   522 
   533 	// Delete unused options
   523 	// Delete unused options
   534 	$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show', 'rss_language');
   524 	$unusedoptions = array(
       
   525 		'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory',
       
   526 		'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping',
       
   527 		'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers',
       
   528 		'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference',
       
   529 		'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char',
       
   530 		'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1',
       
   531 		'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5',
       
   532 		'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9',
       
   533 		'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat',
       
   534 		'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce',
       
   535 		'_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins',
       
   536 		'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
       
   537 		'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
       
   538 		'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
       
   539 		'autoembed_urls', 'default_post_edit_rows',
       
   540 	);
   535 	foreach ( $unusedoptions as $option )
   541 	foreach ( $unusedoptions as $option )
   536 		delete_option($option);
   542 		delete_option($option);
   537 
   543 
   538 	// delete obsolete magpie stuff
   544 	// delete obsolete magpie stuff
   539 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
   545 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
   784 
   790 
   785 	if ( !empty( $role ) ) {
   791 	if ( !empty( $role ) ) {
   786 		$role->add_cap( 'update_core' );
   792 		$role->add_cap( 'update_core' );
   787 		$role->add_cap( 'list_users' );
   793 		$role->add_cap( 'list_users' );
   788 		$role->add_cap( 'remove_users' );
   794 		$role->add_cap( 'remove_users' );
       
   795 
       
   796 		// Never used, will be removed. create_users or
       
   797 		// promote_users is the capability you're looking for.
   789 		$role->add_cap( 'add_users' );
   798 		$role->add_cap( 'add_users' );
       
   799 
   790 		$role->add_cap( 'promote_users' );
   800 		$role->add_cap( 'promote_users' );
   791 		$role->add_cap( 'edit_theme_options' );
   801 		$role->add_cap( 'edit_theme_options' );
   792 		$role->add_cap( 'delete_themes' );
   802 		$role->add_cap( 'delete_themes' );
   793 		$role->add_cap( 'export' );
   803 		$role->add_cap( 'export' );
   794 	}
   804 	}
   896 		'welcome_email' => $welcome_email,
   906 		'welcome_email' => $welcome_email,
   897 		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
   907 		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
   898 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
   908 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
   899 		'siteurl' => get_option( 'siteurl' ) . '/',
   909 		'siteurl' => get_option( 'siteurl' ) . '/',
   900 		'add_new_users' => '0',
   910 		'add_new_users' => '0',
   901 		'upload_space_check_disabled' => '0',
   911 		'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1',
   902 		'subdomain_install' => intval( $subdomain_install ),
   912 		'subdomain_install' => intval( $subdomain_install ),
   903 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
   913 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
       
   914 		'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
   904 		'initial_db_version' => get_option( 'initial_db_version' ),
   915 		'initial_db_version' => get_option( 'initial_db_version' ),
   905 		'active_sitewide_plugins' => array(),
   916 		'active_sitewide_plugins' => array(),
       
   917 		'WPLANG' => get_locale(),
   906 	);
   918 	);
   907 	if ( ! $subdomain_install )
   919 	if ( ! $subdomain_install )
   908 		$sitemeta['illegal_names'][] = 'blog';
   920 		$sitemeta['illegal_names'][] = 'blog';
   909 
   921 
   910 	$insert = '';
   922 	$insert = '';
   917 			$insert .= ', ';
   929 			$insert .= ', ';
   918 		$insert .= "( $network_id, '$meta_key', '$meta_value')";
   930 		$insert .= "( $network_id, '$meta_key', '$meta_value')";
   919 	}
   931 	}
   920 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
   932 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
   921 
   933 
   922 	$current_site->domain = $domain;
   934 	// When upgrading from single to multisite, assume the current site will become the main site of the network.
   923 	$current_site->path = $path;
   935 	// When using populate_network() to create another network in an existing multisite environment,
   924 	$current_site->site_name = ucfirst( $domain );
   936 	// skip these steps since the main site of the new network has not yet been created.
   925 
   937 	if ( ! is_multisite() ) {
   926 	if ( !is_multisite() ) {
   938 		$current_site = new stdClass;
       
   939 		$current_site->domain = $domain;
       
   940 		$current_site->path = $path;
       
   941 		$current_site->site_name = ucfirst( $domain );
   927 		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
   942 		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
   928 		$blog_id = $wpdb->insert_id;
   943 		$current_site->blog_id = $blog_id = $wpdb->insert_id;
   929 		update_user_meta( $site_user->ID, 'source_domain', $domain );
   944 		update_user_meta( $site_user->ID, 'source_domain', $domain );
   930 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
   945 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
   931 		if ( !$upload_path = get_option( 'upload_path' ) ) {
   946 
   932 			$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
   947 		if ( $subdomain_install )
   933 			update_option( 'upload_path', $upload_path );
   948 			$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
   934 		}
   949 		else
   935 		update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
   950 			$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
   936 	}
   951 
   937 
   952 		flush_rewrite_rules();
   938 	if ( $subdomain_install )
   953 	}
   939 		$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
       
   940 	else
       
   941 		$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
       
   942 
       
   943 	flush_rewrite_rules();
       
   944 
   954 
   945 	if ( $subdomain_install ) {
   955 	if ( $subdomain_install ) {
   946 		$vhost_ok = false;
   956 		$vhost_ok = false;
   947 		$errstr = '';
   957 		$errstr = '';
   948 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
   958 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!