wp/wp-admin/includes/schema.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    36 function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
    36 function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
    37 	global $wpdb;
    37 	global $wpdb;
    38 
    38 
    39 	$charset_collate = $wpdb->get_charset_collate();
    39 	$charset_collate = $wpdb->get_charset_collate();
    40 
    40 
    41 	if ( $blog_id && $blog_id != $wpdb->blogid )
    41 	if ( $blog_id && $blog_id != $wpdb->blogid ) {
    42 		$old_blog_id = $wpdb->set_blog_id( $blog_id );
    42 		$old_blog_id = $wpdb->set_blog_id( $blog_id );
       
    43 	}
    43 
    44 
    44 	// Engage multisite if in the middle of turning it on from network.php.
    45 	// Engage multisite if in the middle of turning it on from network.php.
    45 	$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
    46 	$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
    46 
    47 
    47 	/*
    48 	/*
    51 	 */
    52 	 */
    52 	$max_index_length = 191;
    53 	$max_index_length = 191;
    53 
    54 
    54 	// Blog specific tables.
    55 	// Blog specific tables.
    55 	$blog_tables = "CREATE TABLE $wpdb->termmeta (
    56 	$blog_tables = "CREATE TABLE $wpdb->termmeta (
    56   meta_id bigint(20) unsigned NOT NULL auto_increment,
    57 	meta_id bigint(20) unsigned NOT NULL auto_increment,
    57   term_id bigint(20) unsigned NOT NULL default '0',
    58 	term_id bigint(20) unsigned NOT NULL default '0',
    58   meta_key varchar(255) default NULL,
    59 	meta_key varchar(255) default NULL,
    59   meta_value longtext,
    60 	meta_value longtext,
    60   PRIMARY KEY  (meta_id),
    61 	PRIMARY KEY  (meta_id),
    61   KEY term_id (term_id),
    62 	KEY term_id (term_id),
    62   KEY meta_key (meta_key($max_index_length))
    63 	KEY meta_key (meta_key($max_index_length))
    63 ) $charset_collate;
    64 ) $charset_collate;
    64 CREATE TABLE $wpdb->terms (
    65 CREATE TABLE $wpdb->terms (
    65  term_id bigint(20) unsigned NOT NULL auto_increment,
    66  term_id bigint(20) unsigned NOT NULL auto_increment,
    66  name varchar(200) NOT NULL default '',
    67  name varchar(200) NOT NULL default '',
    67  slug varchar(200) NOT NULL default '',
    68  slug varchar(200) NOT NULL default '',
    87  term_order int(11) NOT NULL default 0,
    88  term_order int(11) NOT NULL default 0,
    88  PRIMARY KEY  (object_id,term_taxonomy_id),
    89  PRIMARY KEY  (object_id,term_taxonomy_id),
    89  KEY term_taxonomy_id (term_taxonomy_id)
    90  KEY term_taxonomy_id (term_taxonomy_id)
    90 ) $charset_collate;
    91 ) $charset_collate;
    91 CREATE TABLE $wpdb->commentmeta (
    92 CREATE TABLE $wpdb->commentmeta (
    92   meta_id bigint(20) unsigned NOT NULL auto_increment,
    93 	meta_id bigint(20) unsigned NOT NULL auto_increment,
    93   comment_id bigint(20) unsigned NOT NULL default '0',
    94 	comment_id bigint(20) unsigned NOT NULL default '0',
    94   meta_key varchar(255) default NULL,
    95 	meta_key varchar(255) default NULL,
    95   meta_value longtext,
    96 	meta_value longtext,
    96   PRIMARY KEY  (meta_id),
    97 	PRIMARY KEY  (meta_id),
    97   KEY comment_id (comment_id),
    98 	KEY comment_id (comment_id),
    98   KEY meta_key (meta_key($max_index_length))
    99 	KEY meta_key (meta_key($max_index_length))
    99 ) $charset_collate;
   100 ) $charset_collate;
   100 CREATE TABLE $wpdb->comments (
   101 CREATE TABLE $wpdb->comments (
   101   comment_ID bigint(20) unsigned NOT NULL auto_increment,
   102 	comment_ID bigint(20) unsigned NOT NULL auto_increment,
   102   comment_post_ID bigint(20) unsigned NOT NULL default '0',
   103 	comment_post_ID bigint(20) unsigned NOT NULL default '0',
   103   comment_author tinytext NOT NULL,
   104 	comment_author tinytext NOT NULL,
   104   comment_author_email varchar(100) NOT NULL default '',
   105 	comment_author_email varchar(100) NOT NULL default '',
   105   comment_author_url varchar(200) NOT NULL default '',
   106 	comment_author_url varchar(200) NOT NULL default '',
   106   comment_author_IP varchar(100) NOT NULL default '',
   107 	comment_author_IP varchar(100) NOT NULL default '',
   107   comment_date datetime NOT NULL default '0000-00-00 00:00:00',
   108 	comment_date datetime NOT NULL default '0000-00-00 00:00:00',
   108   comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   109 	comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   109   comment_content text NOT NULL,
   110 	comment_content text NOT NULL,
   110   comment_karma int(11) NOT NULL default '0',
   111 	comment_karma int(11) NOT NULL default '0',
   111   comment_approved varchar(20) NOT NULL default '1',
   112 	comment_approved varchar(20) NOT NULL default '1',
   112   comment_agent varchar(255) NOT NULL default '',
   113 	comment_agent varchar(255) NOT NULL default '',
   113   comment_type varchar(20) NOT NULL default '',
   114 	comment_type varchar(20) NOT NULL default '',
   114   comment_parent bigint(20) unsigned NOT NULL default '0',
   115 	comment_parent bigint(20) unsigned NOT NULL default '0',
   115   user_id bigint(20) unsigned NOT NULL default '0',
   116 	user_id bigint(20) unsigned NOT NULL default '0',
   116   PRIMARY KEY  (comment_ID),
   117 	PRIMARY KEY  (comment_ID),
   117   KEY comment_post_ID (comment_post_ID),
   118 	KEY comment_post_ID (comment_post_ID),
   118   KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
   119 	KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
   119   KEY comment_date_gmt (comment_date_gmt),
   120 	KEY comment_date_gmt (comment_date_gmt),
   120   KEY comment_parent (comment_parent),
   121 	KEY comment_parent (comment_parent),
   121   KEY comment_author_email (comment_author_email(10))
   122 	KEY comment_author_email (comment_author_email(10))
   122 ) $charset_collate;
   123 ) $charset_collate;
   123 CREATE TABLE $wpdb->links (
   124 CREATE TABLE $wpdb->links (
   124   link_id bigint(20) unsigned NOT NULL auto_increment,
   125 	link_id bigint(20) unsigned NOT NULL auto_increment,
   125   link_url varchar(255) NOT NULL default '',
   126 	link_url varchar(255) NOT NULL default '',
   126   link_name varchar(255) NOT NULL default '',
   127 	link_name varchar(255) NOT NULL default '',
   127   link_image varchar(255) NOT NULL default '',
   128 	link_image varchar(255) NOT NULL default '',
   128   link_target varchar(25) NOT NULL default '',
   129 	link_target varchar(25) NOT NULL default '',
   129   link_description varchar(255) NOT NULL default '',
   130 	link_description varchar(255) NOT NULL default '',
   130   link_visible varchar(20) NOT NULL default 'Y',
   131 	link_visible varchar(20) NOT NULL default 'Y',
   131   link_owner bigint(20) unsigned NOT NULL default '1',
   132 	link_owner bigint(20) unsigned NOT NULL default '1',
   132   link_rating int(11) NOT NULL default '0',
   133 	link_rating int(11) NOT NULL default '0',
   133   link_updated datetime NOT NULL default '0000-00-00 00:00:00',
   134 	link_updated datetime NOT NULL default '0000-00-00 00:00:00',
   134   link_rel varchar(255) NOT NULL default '',
   135 	link_rel varchar(255) NOT NULL default '',
   135   link_notes mediumtext NOT NULL,
   136 	link_notes mediumtext NOT NULL,
   136   link_rss varchar(255) NOT NULL default '',
   137 	link_rss varchar(255) NOT NULL default '',
   137   PRIMARY KEY  (link_id),
   138 	PRIMARY KEY  (link_id),
   138   KEY link_visible (link_visible)
   139 	KEY link_visible (link_visible)
   139 ) $charset_collate;
   140 ) $charset_collate;
   140 CREATE TABLE $wpdb->options (
   141 CREATE TABLE $wpdb->options (
   141   option_id bigint(20) unsigned NOT NULL auto_increment,
   142 	option_id bigint(20) unsigned NOT NULL auto_increment,
   142   option_name varchar(191) NOT NULL default '',
   143 	option_name varchar(191) NOT NULL default '',
   143   option_value longtext NOT NULL,
   144 	option_value longtext NOT NULL,
   144   autoload varchar(20) NOT NULL default 'yes',
   145 	autoload varchar(20) NOT NULL default 'yes',
   145   PRIMARY KEY  (option_id),
   146 	PRIMARY KEY  (option_id),
   146   UNIQUE KEY option_name (option_name)
   147 	UNIQUE KEY option_name (option_name)
   147 ) $charset_collate;
   148 ) $charset_collate;
   148 CREATE TABLE $wpdb->postmeta (
   149 CREATE TABLE $wpdb->postmeta (
   149   meta_id bigint(20) unsigned NOT NULL auto_increment,
   150 	meta_id bigint(20) unsigned NOT NULL auto_increment,
   150   post_id bigint(20) unsigned NOT NULL default '0',
   151 	post_id bigint(20) unsigned NOT NULL default '0',
   151   meta_key varchar(255) default NULL,
   152 	meta_key varchar(255) default NULL,
   152   meta_value longtext,
   153 	meta_value longtext,
   153   PRIMARY KEY  (meta_id),
   154 	PRIMARY KEY  (meta_id),
   154   KEY post_id (post_id),
   155 	KEY post_id (post_id),
   155   KEY meta_key (meta_key($max_index_length))
   156 	KEY meta_key (meta_key($max_index_length))
   156 ) $charset_collate;
   157 ) $charset_collate;
   157 CREATE TABLE $wpdb->posts (
   158 CREATE TABLE $wpdb->posts (
   158   ID bigint(20) unsigned NOT NULL auto_increment,
   159 	ID bigint(20) unsigned NOT NULL auto_increment,
   159   post_author bigint(20) unsigned NOT NULL default '0',
   160 	post_author bigint(20) unsigned NOT NULL default '0',
   160   post_date datetime NOT NULL default '0000-00-00 00:00:00',
   161 	post_date datetime NOT NULL default '0000-00-00 00:00:00',
   161   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   162 	post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   162   post_content longtext NOT NULL,
   163 	post_content longtext NOT NULL,
   163   post_title text NOT NULL,
   164 	post_title text NOT NULL,
   164   post_excerpt text NOT NULL,
   165 	post_excerpt text NOT NULL,
   165   post_status varchar(20) NOT NULL default 'publish',
   166 	post_status varchar(20) NOT NULL default 'publish',
   166   comment_status varchar(20) NOT NULL default 'open',
   167 	comment_status varchar(20) NOT NULL default 'open',
   167   ping_status varchar(20) NOT NULL default 'open',
   168 	ping_status varchar(20) NOT NULL default 'open',
   168   post_password varchar(255) NOT NULL default '',
   169 	post_password varchar(255) NOT NULL default '',
   169   post_name varchar(200) NOT NULL default '',
   170 	post_name varchar(200) NOT NULL default '',
   170   to_ping text NOT NULL,
   171 	to_ping text NOT NULL,
   171   pinged text NOT NULL,
   172 	pinged text NOT NULL,
   172   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
   173 	post_modified datetime NOT NULL default '0000-00-00 00:00:00',
   173   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   174 	post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   174   post_content_filtered longtext NOT NULL,
   175 	post_content_filtered longtext NOT NULL,
   175   post_parent bigint(20) unsigned NOT NULL default '0',
   176 	post_parent bigint(20) unsigned NOT NULL default '0',
   176   guid varchar(255) NOT NULL default '',
   177 	guid varchar(255) NOT NULL default '',
   177   menu_order int(11) NOT NULL default '0',
   178 	menu_order int(11) NOT NULL default '0',
   178   post_type varchar(20) NOT NULL default 'post',
   179 	post_type varchar(20) NOT NULL default 'post',
   179   post_mime_type varchar(100) NOT NULL default '',
   180 	post_mime_type varchar(100) NOT NULL default '',
   180   comment_count bigint(20) NOT NULL default '0',
   181 	comment_count bigint(20) NOT NULL default '0',
   181   PRIMARY KEY  (ID),
   182 	PRIMARY KEY  (ID),
   182   KEY post_name (post_name($max_index_length)),
   183 	KEY post_name (post_name($max_index_length)),
   183   KEY type_status_date (post_type,post_status,post_date,ID),
   184 	KEY type_status_date (post_type,post_status,post_date,ID),
   184   KEY post_parent (post_parent),
   185 	KEY post_parent (post_parent),
   185   KEY post_author (post_author)
   186 	KEY post_author (post_author)
   186 ) $charset_collate;\n";
   187 ) $charset_collate;\n";
   187 
   188 
   188 	// Single site users table. The multisite flavor of the users table is handled below.
   189 	// Single site users table. The multisite flavor of the users table is handled below.
   189 	$users_single_table = "CREATE TABLE $wpdb->users (
   190 	$users_single_table = "CREATE TABLE $wpdb->users (
   190   ID bigint(20) unsigned NOT NULL auto_increment,
   191 	ID bigint(20) unsigned NOT NULL auto_increment,
   191   user_login varchar(60) NOT NULL default '',
   192 	user_login varchar(60) NOT NULL default '',
   192   user_pass varchar(255) NOT NULL default '',
   193 	user_pass varchar(255) NOT NULL default '',
   193   user_nicename varchar(50) NOT NULL default '',
   194 	user_nicename varchar(50) NOT NULL default '',
   194   user_email varchar(100) NOT NULL default '',
   195 	user_email varchar(100) NOT NULL default '',
   195   user_url varchar(100) NOT NULL default '',
   196 	user_url varchar(100) NOT NULL default '',
   196   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
   197 	user_registered datetime NOT NULL default '0000-00-00 00:00:00',
   197   user_activation_key varchar(255) NOT NULL default '',
   198 	user_activation_key varchar(255) NOT NULL default '',
   198   user_status int(11) NOT NULL default '0',
   199 	user_status int(11) NOT NULL default '0',
   199   display_name varchar(250) NOT NULL default '',
   200 	display_name varchar(250) NOT NULL default '',
   200   PRIMARY KEY  (ID),
   201 	PRIMARY KEY  (ID),
   201   KEY user_login_key (user_login),
   202 	KEY user_login_key (user_login),
   202   KEY user_nicename (user_nicename),
   203 	KEY user_nicename (user_nicename),
   203   KEY user_email (user_email)
   204 	KEY user_email (user_email)
   204 ) $charset_collate;\n";
   205 ) $charset_collate;\n";
   205 
   206 
   206 	// Multisite users table
   207 	// Multisite users table
   207 	$users_multi_table = "CREATE TABLE $wpdb->users (
   208 	$users_multi_table = "CREATE TABLE $wpdb->users (
   208   ID bigint(20) unsigned NOT NULL auto_increment,
   209 	ID bigint(20) unsigned NOT NULL auto_increment,
   209   user_login varchar(60) NOT NULL default '',
   210 	user_login varchar(60) NOT NULL default '',
   210   user_pass varchar(255) NOT NULL default '',
   211 	user_pass varchar(255) NOT NULL default '',
   211   user_nicename varchar(50) NOT NULL default '',
   212 	user_nicename varchar(50) NOT NULL default '',
   212   user_email varchar(100) NOT NULL default '',
   213 	user_email varchar(100) NOT NULL default '',
   213   user_url varchar(100) NOT NULL default '',
   214 	user_url varchar(100) NOT NULL default '',
   214   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
   215 	user_registered datetime NOT NULL default '0000-00-00 00:00:00',
   215   user_activation_key varchar(255) NOT NULL default '',
   216 	user_activation_key varchar(255) NOT NULL default '',
   216   user_status int(11) NOT NULL default '0',
   217 	user_status int(11) NOT NULL default '0',
   217   display_name varchar(250) NOT NULL default '',
   218 	display_name varchar(250) NOT NULL default '',
   218   spam tinyint(2) NOT NULL default '0',
   219 	spam tinyint(2) NOT NULL default '0',
   219   deleted tinyint(2) NOT NULL default '0',
   220 	deleted tinyint(2) NOT NULL default '0',
   220   PRIMARY KEY  (ID),
   221 	PRIMARY KEY  (ID),
   221   KEY user_login_key (user_login),
   222 	KEY user_login_key (user_login),
   222   KEY user_nicename (user_nicename),
   223 	KEY user_nicename (user_nicename),
   223   KEY user_email (user_email)
   224 	KEY user_email (user_email)
   224 ) $charset_collate;\n";
   225 ) $charset_collate;\n";
   225 
   226 
   226 	// Usermeta.
   227 	// Usermeta.
   227 	$usermeta_table = "CREATE TABLE $wpdb->usermeta (
   228 	$usermeta_table = "CREATE TABLE $wpdb->usermeta (
   228   umeta_id bigint(20) unsigned NOT NULL auto_increment,
   229 	umeta_id bigint(20) unsigned NOT NULL auto_increment,
   229   user_id bigint(20) unsigned NOT NULL default '0',
   230 	user_id bigint(20) unsigned NOT NULL default '0',
   230   meta_key varchar(255) default NULL,
   231 	meta_key varchar(255) default NULL,
   231   meta_value longtext,
   232 	meta_value longtext,
   232   PRIMARY KEY  (umeta_id),
   233 	PRIMARY KEY  (umeta_id),
   233   KEY user_id (user_id),
   234 	KEY user_id (user_id),
   234   KEY meta_key (meta_key($max_index_length))
   235 	KEY meta_key (meta_key($max_index_length))
   235 ) $charset_collate;\n";
   236 ) $charset_collate;\n";
   236 
   237 
   237 	// Global tables
   238 	// Global tables
   238 	if ( $is_multisite )
   239 	if ( $is_multisite ) {
   239 		$global_tables = $users_multi_table . $usermeta_table;
   240 		$global_tables = $users_multi_table . $usermeta_table;
   240 	else
   241 	} else {
   241 		$global_tables = $users_single_table . $usermeta_table;
   242 		$global_tables = $users_single_table . $usermeta_table;
       
   243 	}
   242 
   244 
   243 	// Multisite global tables.
   245 	// Multisite global tables.
   244 	$ms_global_tables = "CREATE TABLE $wpdb->blogs (
   246 	$ms_global_tables = "CREATE TABLE $wpdb->blogs (
   245   blog_id bigint(20) NOT NULL auto_increment,
   247 	blog_id bigint(20) NOT NULL auto_increment,
   246   site_id bigint(20) NOT NULL default '0',
   248 	site_id bigint(20) NOT NULL default '0',
   247   domain varchar(200) NOT NULL default '',
   249 	domain varchar(200) NOT NULL default '',
   248   path varchar(100) NOT NULL default '',
   250 	path varchar(100) NOT NULL default '',
   249   registered datetime NOT NULL default '0000-00-00 00:00:00',
   251 	registered datetime NOT NULL default '0000-00-00 00:00:00',
   250   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
   252 	last_updated datetime NOT NULL default '0000-00-00 00:00:00',
   251   public tinyint(2) NOT NULL default '1',
   253 	public tinyint(2) NOT NULL default '1',
   252   archived tinyint(2) NOT NULL default '0',
   254 	archived tinyint(2) NOT NULL default '0',
   253   mature tinyint(2) NOT NULL default '0',
   255 	mature tinyint(2) NOT NULL default '0',
   254   spam tinyint(2) NOT NULL default '0',
   256 	spam tinyint(2) NOT NULL default '0',
   255   deleted tinyint(2) NOT NULL default '0',
   257 	deleted tinyint(2) NOT NULL default '0',
   256   lang_id int(11) NOT NULL default '0',
   258 	lang_id int(11) NOT NULL default '0',
   257   PRIMARY KEY  (blog_id),
   259 	PRIMARY KEY  (blog_id),
   258   KEY domain (domain(50),path(5)),
   260 	KEY domain (domain(50),path(5)),
   259   KEY lang_id (lang_id)
   261 	KEY lang_id (lang_id)
   260 ) $charset_collate;
   262 ) $charset_collate;
   261 CREATE TABLE $wpdb->blog_versions (
   263 CREATE TABLE $wpdb->blog_versions (
   262   blog_id bigint(20) NOT NULL default '0',
   264 	blog_id bigint(20) NOT NULL default '0',
   263   db_version varchar(20) NOT NULL default '',
   265 	db_version varchar(20) NOT NULL default '',
   264   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
   266 	last_updated datetime NOT NULL default '0000-00-00 00:00:00',
   265   PRIMARY KEY  (blog_id),
   267 	PRIMARY KEY  (blog_id),
   266   KEY db_version (db_version)
   268 	KEY db_version (db_version)
       
   269 ) $charset_collate;
       
   270 CREATE TABLE $wpdb->blogmeta (
       
   271 	meta_id bigint(20) unsigned NOT NULL auto_increment,
       
   272 	blog_id bigint(20) NOT NULL default '0',
       
   273 	meta_key varchar(255) default NULL,
       
   274 	meta_value longtext,
       
   275 	PRIMARY KEY  (meta_id),
       
   276 	KEY meta_key (meta_key($max_index_length)),
       
   277 	KEY blog_id (blog_id)
   267 ) $charset_collate;
   278 ) $charset_collate;
   268 CREATE TABLE $wpdb->registration_log (
   279 CREATE TABLE $wpdb->registration_log (
   269   ID bigint(20) NOT NULL auto_increment,
   280 	ID bigint(20) NOT NULL auto_increment,
   270   email varchar(255) NOT NULL default '',
   281 	email varchar(255) NOT NULL default '',
   271   IP varchar(30) NOT NULL default '',
   282 	IP varchar(30) NOT NULL default '',
   272   blog_id bigint(20) NOT NULL default '0',
   283 	blog_id bigint(20) NOT NULL default '0',
   273   date_registered datetime NOT NULL default '0000-00-00 00:00:00',
   284 	date_registered datetime NOT NULL default '0000-00-00 00:00:00',
   274   PRIMARY KEY  (ID),
   285 	PRIMARY KEY  (ID),
   275   KEY IP (IP)
   286 	KEY IP (IP)
   276 ) $charset_collate;
   287 ) $charset_collate;
   277 CREATE TABLE $wpdb->site (
   288 CREATE TABLE $wpdb->site (
   278   id bigint(20) NOT NULL auto_increment,
   289 	id bigint(20) NOT NULL auto_increment,
   279   domain varchar(200) NOT NULL default '',
   290 	domain varchar(200) NOT NULL default '',
   280   path varchar(100) NOT NULL default '',
   291 	path varchar(100) NOT NULL default '',
   281   PRIMARY KEY  (id),
   292 	PRIMARY KEY  (id),
   282   KEY domain (domain(140),path(51))
   293 	KEY domain (domain(140),path(51))
   283 ) $charset_collate;
   294 ) $charset_collate;
   284 CREATE TABLE $wpdb->sitemeta (
   295 CREATE TABLE $wpdb->sitemeta (
   285   meta_id bigint(20) NOT NULL auto_increment,
   296 	meta_id bigint(20) NOT NULL auto_increment,
   286   site_id bigint(20) NOT NULL default '0',
   297 	site_id bigint(20) NOT NULL default '0',
   287   meta_key varchar(255) default NULL,
   298 	meta_key varchar(255) default NULL,
   288   meta_value longtext,
   299 	meta_value longtext,
   289   PRIMARY KEY  (meta_id),
   300 	PRIMARY KEY  (meta_id),
   290   KEY meta_key (meta_key($max_index_length)),
   301 	KEY meta_key (meta_key($max_index_length)),
   291   KEY site_id (site_id)
   302 	KEY site_id (site_id)
   292 ) $charset_collate;
   303 ) $charset_collate;
   293 CREATE TABLE $wpdb->signups (
   304 CREATE TABLE $wpdb->signups (
   294   signup_id bigint(20) NOT NULL auto_increment,
   305 	signup_id bigint(20) NOT NULL auto_increment,
   295   domain varchar(200) NOT NULL default '',
   306 	domain varchar(200) NOT NULL default '',
   296   path varchar(100) NOT NULL default '',
   307 	path varchar(100) NOT NULL default '',
   297   title longtext NOT NULL,
   308 	title longtext NOT NULL,
   298   user_login varchar(60) NOT NULL default '',
   309 	user_login varchar(60) NOT NULL default '',
   299   user_email varchar(100) NOT NULL default '',
   310 	user_email varchar(100) NOT NULL default '',
   300   registered datetime NOT NULL default '0000-00-00 00:00:00',
   311 	registered datetime NOT NULL default '0000-00-00 00:00:00',
   301   activated datetime NOT NULL default '0000-00-00 00:00:00',
   312 	activated datetime NOT NULL default '0000-00-00 00:00:00',
   302   active tinyint(1) NOT NULL default '0',
   313 	active tinyint(1) NOT NULL default '0',
   303   activation_key varchar(50) NOT NULL default '',
   314 	activation_key varchar(50) NOT NULL default '',
   304   meta longtext,
   315 	meta longtext,
   305   PRIMARY KEY  (signup_id),
   316 	PRIMARY KEY  (signup_id),
   306   KEY activation_key (activation_key),
   317 	KEY activation_key (activation_key),
   307   KEY user_email (user_email),
   318 	KEY user_email (user_email),
   308   KEY user_login_email (user_login,user_email),
   319 	KEY user_login_email (user_login,user_email),
   309   KEY domain_path (domain(140),path(51))
   320 	KEY domain_path (domain(140),path(51))
   310 ) $charset_collate;";
   321 ) $charset_collate;";
   311 
   322 
   312 	switch ( $scope ) {
   323 	switch ( $scope ) {
   313 		case 'blog' :
   324 		case 'blog':
   314 			$queries = $blog_tables;
   325 			$queries = $blog_tables;
   315 			break;
   326 			break;
   316 		case 'global' :
   327 		case 'global':
   317 			$queries = $global_tables;
   328 			$queries = $global_tables;
   318 			if ( $is_multisite )
   329 			if ( $is_multisite ) {
   319 				$queries .= $ms_global_tables;
   330 				$queries .= $ms_global_tables;
       
   331 			}
   320 			break;
   332 			break;
   321 		case 'ms_global' :
   333 		case 'ms_global':
   322 			$queries = $ms_global_tables;
   334 			$queries = $ms_global_tables;
   323 			break;
   335 			break;
   324 		case 'all' :
   336 		case 'all':
   325 		default:
   337 		default:
   326 			$queries = $global_tables . $blog_tables;
   338 			$queries = $global_tables . $blog_tables;
   327 			if ( $is_multisite )
   339 			if ( $is_multisite ) {
   328 				$queries .= $ms_global_tables;
   340 				$queries .= $ms_global_tables;
       
   341 			}
   329 			break;
   342 			break;
   330 	}
   343 	}
   331 
   344 
   332 	if ( isset( $old_blog_id ) )
   345 	if ( isset( $old_blog_id ) ) {
   333 		$wpdb->set_blog_id( $old_blog_id );
   346 		$wpdb->set_blog_id( $old_blog_id );
       
   347 	}
   334 
   348 
   335 	return $queries;
   349 	return $queries;
   336 }
   350 }
   337 
   351 
   338 // Populate for back compat.
   352 // Populate for back compat.
   340 
   354 
   341 /**
   355 /**
   342  * Create WordPress options and set the default values.
   356  * Create WordPress options and set the default values.
   343  *
   357  *
   344  * @since 1.5.0
   358  * @since 1.5.0
       
   359  * @since 5.1.0 The $options parameter has been added.
   345  *
   360  *
   346  * @global wpdb $wpdb WordPress database abstraction object.
   361  * @global wpdb $wpdb WordPress database abstraction object.
   347  * @global int  $wp_db_version
   362  * @global int  $wp_db_version
   348  * @global int  $wp_current_db_version
   363  * @global int  $wp_current_db_version
   349  */
   364  *
   350 function populate_options() {
   365  * @param array $options Optional. Custom option $key => $value pairs to use. Default empty array.
       
   366  */
       
   367 function populate_options( array $options = array() ) {
   351 	global $wpdb, $wp_db_version, $wp_current_db_version;
   368 	global $wpdb, $wp_db_version, $wp_current_db_version;
   352 
   369 
   353 	$guessurl = wp_guess_url();
   370 	$guessurl = wp_guess_url();
   354 	/**
   371 	/**
   355 	 * Fires before creating WordPress options and populating their default values.
   372 	 * Fires before creating WordPress options and populating their default values.
   356 	 *
   373 	 *
   357 	 * @since 2.6.0
   374 	 * @since 2.6.0
   358 	 */
   375 	 */
   359 	do_action( 'populate_options' );
   376 	do_action( 'populate_options' );
   360 
   377 
   361 	if ( ini_get('safe_mode') ) {
   378 	if ( ini_get( 'safe_mode' ) ) {
   362 		// Safe mode can break mkdir() so use a flat structure by default.
   379 		// Safe mode can break mkdir() so use a flat structure by default.
   363 		$uploads_use_yearmonth_folders = 0;
   380 		$uploads_use_yearmonth_folders = 0;
   364 	} else {
   381 	} else {
   365 		$uploads_use_yearmonth_folders = 1;
   382 		$uploads_use_yearmonth_folders = 1;
   366 	}
   383 	}
   367 
   384 
   368 	// If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
   385 	// If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.
   369 	$stylesheet = $template = WP_DEFAULT_THEME;
   386 	$stylesheet = WP_DEFAULT_THEME;
   370 	$theme = wp_get_theme( WP_DEFAULT_THEME );
   387 	$template   = WP_DEFAULT_THEME;
       
   388 	$theme      = wp_get_theme( WP_DEFAULT_THEME );
   371 	if ( ! $theme->exists() ) {
   389 	if ( ! $theme->exists() ) {
   372 		$theme = WP_Theme::get_core_default_theme();
   390 		$theme = WP_Theme::get_core_default_theme();
   373 	}
   391 	}
   374 
   392 
   375 	// If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.
   393 	// If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do.
   377 		$stylesheet = $theme->get_stylesheet();
   395 		$stylesheet = $theme->get_stylesheet();
   378 		$template   = $theme->get_template();
   396 		$template   = $theme->get_template();
   379 	}
   397 	}
   380 
   398 
   381 	$timezone_string = '';
   399 	$timezone_string = '';
   382 	$gmt_offset = 0;
   400 	$gmt_offset      = 0;
   383 	/* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14)
   401 	/*
   384 	   or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php
   402 	 * translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14)
   385 	   for all timezone strings supported by PHP.
   403 	 * or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php
   386 	*/
   404 	 * for all timezone strings supported by PHP.
   387 	$offset_or_tz = _x( '0', 'default GMT offset or timezone string' );
   405 	 */
   388 	if ( is_numeric( $offset_or_tz ) )
   406 	$offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings
       
   407 	if ( is_numeric( $offset_or_tz ) ) {
   389 		$gmt_offset = $offset_or_tz;
   408 		$gmt_offset = $offset_or_tz;
   390 	elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) )
   409 	} elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) {
   391 			$timezone_string = $offset_or_tz;
   410 			$timezone_string = $offset_or_tz;
   392 
   411 	}
   393 	$options = array(
   412 
   394 	'siteurl' => $guessurl,
   413 	$defaults = array(
   395 	'home' => $guessurl,
   414 		'siteurl'                         => $guessurl,
   396 	'blogname' => __('My Site'),
   415 		'home'                            => $guessurl,
   397 	/* translators: site tagline */
   416 		'blogname'                        => __( 'My Site' ),
   398 	'blogdescription' => __('Just another WordPress site'),
   417 		/* translators: site tagline */
   399 	'users_can_register' => 0,
   418 		'blogdescription'                 => __( 'Just another WordPress site' ),
   400 	'admin_email' => 'you@example.com',
   419 		'users_can_register'              => 0,
   401 	/* translators: default start of the week. 0 = Sunday, 1 = Monday */
   420 		'admin_email'                     => 'you@example.com',
   402 	'start_of_week' => _x( '1', 'start of week' ),
   421 		/* translators: default start of the week. 0 = Sunday, 1 = Monday */
   403 	'use_balanceTags' => 0,
   422 		'start_of_week'                   => _x( '1', 'start of week' ),
   404 	'use_smilies' => 1,
   423 		'use_balanceTags'                 => 0,
   405 	'require_name_email' => 1,
   424 		'use_smilies'                     => 1,
   406 	'comments_notify' => 1,
   425 		'require_name_email'              => 1,
   407 	'posts_per_rss' => 10,
   426 		'comments_notify'                 => 1,
   408 	'rss_use_excerpt' => 0,
   427 		'posts_per_rss'                   => 10,
   409 	'mailserver_url' => 'mail.example.com',
   428 		'rss_use_excerpt'                 => 0,
   410 	'mailserver_login' => 'login@example.com',
   429 		'mailserver_url'                  => 'mail.example.com',
   411 	'mailserver_pass' => 'password',
   430 		'mailserver_login'                => 'login@example.com',
   412 	'mailserver_port' => 110,
   431 		'mailserver_pass'                 => 'password',
   413 	'default_category' => 1,
   432 		'mailserver_port'                 => 110,
   414 	'default_comment_status' => 'open',
   433 		'default_category'                => 1,
   415 	'default_ping_status' => 'open',
   434 		'default_comment_status'          => 'open',
   416 	'default_pingback_flag' => 1,
   435 		'default_ping_status'             => 'open',
   417 	'posts_per_page' => 10,
   436 		'default_pingback_flag'           => 1,
   418 	/* translators: default date format, see https://secure.php.net/date */
   437 		'posts_per_page'                  => 10,
   419 	'date_format' => __('F j, Y'),
   438 		/* translators: default date format, see https://secure.php.net/date */
   420 	/* translators: default time format, see https://secure.php.net/date */
   439 		'date_format'                     => __( 'F j, Y' ),
   421 	'time_format' => __('g:i a'),
   440 		/* translators: default time format, see https://secure.php.net/date */
   422 	/* translators: links last updated date format, see https://secure.php.net/date */
   441 		'time_format'                     => __( 'g:i a' ),
   423 	'links_updated_date_format' => __('F j, Y g:i a'),
   442 		/* translators: links last updated date format, see https://secure.php.net/date */
   424 	'comment_moderation' => 0,
   443 		'links_updated_date_format'       => __( 'F j, Y g:i a' ),
   425 	'moderation_notify' => 1,
   444 		'comment_moderation'              => 0,
   426 	'permalink_structure' => '',
   445 		'moderation_notify'               => 1,
   427 	'rewrite_rules' => '',
   446 		'permalink_structure'             => '',
   428 	'hack_file' => 0,
   447 		'rewrite_rules'                   => '',
   429 	'blog_charset' => 'UTF-8',
   448 		'hack_file'                       => 0,
   430 	'moderation_keys' => '',
   449 		'blog_charset'                    => 'UTF-8',
   431 	'active_plugins' => array(),
   450 		'moderation_keys'                 => '',
   432 	'category_base' => '',
   451 		'active_plugins'                  => array(),
   433 	'ping_sites' => 'http://rpc.pingomatic.com/',
   452 		'category_base'                   => '',
   434 	'comment_max_links' => 2,
   453 		'ping_sites'                      => 'http://rpc.pingomatic.com/',
   435 	'gmt_offset' => $gmt_offset,
   454 		'comment_max_links'               => 2,
   436 
   455 		'gmt_offset'                      => $gmt_offset,
   437 	// 1.5
   456 
   438 	'default_email_category' => 1,
   457 		// 1.5
   439 	'recently_edited' => '',
   458 		'default_email_category'          => 1,
   440 	'template' => $template,
   459 		'recently_edited'                 => '',
   441 	'stylesheet' => $stylesheet,
   460 		'template'                        => $template,
   442 	'comment_whitelist' => 1,
   461 		'stylesheet'                      => $stylesheet,
   443 	'blacklist_keys' => '',
   462 		'comment_whitelist'               => 1,
   444 	'comment_registration' => 0,
   463 		'blacklist_keys'                  => '',
   445 	'html_type' => 'text/html',
   464 		'comment_registration'            => 0,
   446 
   465 		'html_type'                       => 'text/html',
   447 	// 1.5.1
   466 
   448 	'use_trackback' => 0,
   467 		// 1.5.1
   449 
   468 		'use_trackback'                   => 0,
   450 	// 2.0
   469 
   451 	'default_role' => 'subscriber',
   470 		// 2.0
   452 	'db_version' => $wp_db_version,
   471 		'default_role'                    => 'subscriber',
   453 
   472 		'db_version'                      => $wp_db_version,
   454 	// 2.0.1
   473 
   455 	'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
   474 		// 2.0.1
   456 	'upload_path' => '',
   475 		'uploads_use_yearmonth_folders'   => $uploads_use_yearmonth_folders,
   457 
   476 		'upload_path'                     => '',
   458 	// 2.1
   477 
   459 	'blog_public' => '1',
   478 		// 2.1
   460 	'default_link_category' => 2,
   479 		'blog_public'                     => '1',
   461 	'show_on_front' => 'posts',
   480 		'default_link_category'           => 2,
   462 
   481 		'show_on_front'                   => 'posts',
   463 	// 2.2
   482 
   464 	'tag_base' => '',
   483 		// 2.2
   465 
   484 		'tag_base'                        => '',
   466 	// 2.5
   485 
   467 	'show_avatars' => '1',
   486 		// 2.5
   468 	'avatar_rating' => 'G',
   487 		'show_avatars'                    => '1',
   469 	'upload_url_path' => '',
   488 		'avatar_rating'                   => 'G',
   470 	'thumbnail_size_w' => 150,
   489 		'upload_url_path'                 => '',
   471 	'thumbnail_size_h' => 150,
   490 		'thumbnail_size_w'                => 150,
   472 	'thumbnail_crop' => 1,
   491 		'thumbnail_size_h'                => 150,
   473 	'medium_size_w' => 300,
   492 		'thumbnail_crop'                  => 1,
   474 	'medium_size_h' => 300,
   493 		'medium_size_w'                   => 300,
   475 
   494 		'medium_size_h'                   => 300,
   476 	// 2.6
   495 
   477 	'avatar_default' => 'mystery',
   496 		// 2.6
   478 
   497 		'avatar_default'                  => 'mystery',
   479 	// 2.7
   498 
   480 	'large_size_w' => 1024,
   499 		// 2.7
   481 	'large_size_h' => 1024,
   500 		'large_size_w'                    => 1024,
   482 	'image_default_link_type' => 'none',
   501 		'large_size_h'                    => 1024,
   483 	'image_default_size' => '',
   502 		'image_default_link_type'         => 'none',
   484 	'image_default_align' => '',
   503 		'image_default_size'              => '',
   485 	'close_comments_for_old_posts' => 0,
   504 		'image_default_align'             => '',
   486 	'close_comments_days_old' => 14,
   505 		'close_comments_for_old_posts'    => 0,
   487 	'thread_comments' => 1,
   506 		'close_comments_days_old'         => 14,
   488 	'thread_comments_depth' => 5,
   507 		'thread_comments'                 => 1,
   489 	'page_comments' => 0,
   508 		'thread_comments_depth'           => 5,
   490 	'comments_per_page' => 50,
   509 		'page_comments'                   => 0,
   491 	'default_comments_page' => 'newest',
   510 		'comments_per_page'               => 50,
   492 	'comment_order' => 'asc',
   511 		'default_comments_page'           => 'newest',
   493 	'sticky_posts' => array(),
   512 		'comment_order'                   => 'asc',
   494 	'widget_categories' => array(),
   513 		'sticky_posts'                    => array(),
   495 	'widget_text' => array(),
   514 		'widget_categories'               => array(),
   496 	'widget_rss' => array(),
   515 		'widget_text'                     => array(),
   497 	'uninstall_plugins' => array(),
   516 		'widget_rss'                      => array(),
   498 
   517 		'uninstall_plugins'               => array(),
   499 	// 2.8
   518 
   500 	'timezone_string' => $timezone_string,
   519 		// 2.8
   501 
   520 		'timezone_string'                 => $timezone_string,
   502 	// 3.0
   521 
   503 	'page_for_posts' => 0,
   522 		// 3.0
   504 	'page_on_front' => 0,
   523 		'page_for_posts'                  => 0,
   505 
   524 		'page_on_front'                   => 0,
   506 	// 3.1
   525 
   507 	'default_post_format' => 0,
   526 		// 3.1
   508 
   527 		'default_post_format'             => 0,
   509 	// 3.5
   528 
   510 	'link_manager_enabled' => 0,
   529 		// 3.5
   511 
   530 		'link_manager_enabled'            => 0,
   512 	// 4.3.0
   531 
   513 	'finished_splitting_shared_terms' => 1,
   532 		// 4.3.0
   514 	'site_icon' => 0,
   533 		'finished_splitting_shared_terms' => 1,
   515 
   534 		'site_icon'                       => 0,
   516 	// 4.4.0
   535 
   517 	'medium_large_size_w' => 768,
   536 		// 4.4.0
   518 	'medium_large_size_h' => 0,
   537 		'medium_large_size_w'             => 768,
       
   538 		'medium_large_size_h'             => 0,
   519 
   539 
   520 		// 4.9.6
   540 		// 4.9.6
   521 		'wp_page_for_privacy_policy'      => 0,
   541 		'wp_page_for_privacy_policy'      => 0,
   522 
   542 
   523 		// 4.9.8
   543 		// 4.9.8
   524 		'show_comments_cookies_opt_in'    => 0,
   544 		'show_comments_cookies_opt_in'    => 1,
   525 	);
   545 	);
   526 
   546 
   527 	// 3.3
   547 	// 3.3
   528 	if ( ! is_multisite() ) {
   548 	if ( ! is_multisite() ) {
   529 		$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
   549 		$defaults['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
   530 			? $wp_current_db_version : $wp_db_version;
   550 			? $wp_current_db_version : $wp_db_version;
   531 	}
   551 	}
   532 
   552 
   533 	// 3.0 multisite
   553 	// 3.0 multisite
   534 	if ( is_multisite() ) {
   554 	if ( is_multisite() ) {
   535 		/* translators: site tagline */
   555 		/* translators: site tagline */
   536 		$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name );
   556 		$defaults['blogdescription']     = sprintf( __( 'Just another %s site' ), get_network()->site_name );
   537 		$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
   557 		$defaults['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/';
   538 	}
   558 	}
       
   559 
       
   560 	$options = wp_parse_args( $options, $defaults );
   539 
   561 
   540 	// Set autoload to no for these options
   562 	// Set autoload to no for these options
   541 	$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' );
   563 	$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' );
   542 
   564 
   543 	$keys = "'" . implode( "', '", array_keys( $options ) ) . "'";
   565 	$keys             = "'" . implode( "', '", array_keys( $options ) ) . "'";
   544 	$existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" );
   566 	$existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
   545 
   567 
   546 	$insert = '';
   568 	$insert = '';
   547 	foreach ( $options as $option => $value ) {
   569 	foreach ( $options as $option => $value ) {
   548 		if ( in_array($option, $existing_options) )
   570 		if ( in_array( $option, $existing_options ) ) {
   549 			continue;
   571 			continue;
   550 		if ( in_array($option, $fat_options) )
   572 		}
       
   573 		if ( in_array( $option, $fat_options ) ) {
   551 			$autoload = 'no';
   574 			$autoload = 'no';
   552 		else
   575 		} else {
   553 			$autoload = 'yes';
   576 			$autoload = 'yes';
   554 
   577 		}
   555 		if ( is_array($value) )
   578 
   556 			$value = serialize($value);
   579 		if ( is_array( $value ) ) {
   557 		if ( !empty($insert) )
   580 			$value = serialize( $value );
       
   581 		}
       
   582 		if ( ! empty( $insert ) ) {
   558 			$insert .= ', ';
   583 			$insert .= ', ';
   559 		$insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload );
   584 		}
   560 	}
   585 		$insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload );
   561 
   586 	}
   562 	if ( !empty($insert) )
   587 
   563 		$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
   588 	if ( ! empty( $insert ) ) {
       
   589 		$wpdb->query( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
       
   590 	}
   564 
   591 
   565 	// In case it is set, but blank, update "home".
   592 	// In case it is set, but blank, update "home".
   566 	if ( !__get_option('home') ) update_option('home', $guessurl);
   593 	if ( ! __get_option( 'home' ) ) {
       
   594 		update_option( 'home', $guessurl );
       
   595 	}
   567 
   596 
   568 	// Delete unused options.
   597 	// Delete unused options.
   569 	$unusedoptions = array(
   598 	$unusedoptions = array(
   570 		'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory',
   599 		'blodotgsping_url',
   571 		'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping',
   600 		'bodyterminator',
   572 		'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers',
   601 		'emailtestonly',
   573 		'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference',
   602 		'phoneemail_separator',
   574 		'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char',
   603 		'smilies_directory',
   575 		'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1',
   604 		'subjectprefix',
   576 		'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5',
   605 		'use_bbcode',
   577 		'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9',
   606 		'use_blodotgsping',
   578 		'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append',
   607 		'use_phoneemail',
   579 		'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat',
   608 		'use_quicktags',
   580 		'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce',
   609 		'use_weblogsping',
   581 		'_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins',
   610 		'weblogs_cache_file',
   582 		'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
   611 		'use_preview',
   583 		'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
   612 		'use_htmltrans',
   584 		'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
   613 		'smilies_directory',
   585 		'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit'
   614 		'fileupload_allowedusers',
       
   615 		'use_phoneemail',
       
   616 		'default_post_status',
       
   617 		'default_post_category',
       
   618 		'archive_mode',
       
   619 		'time_difference',
       
   620 		'links_minadminlevel',
       
   621 		'links_use_adminlevels',
       
   622 		'links_rating_type',
       
   623 		'links_rating_char',
       
   624 		'links_rating_ignore_zero',
       
   625 		'links_rating_single_image',
       
   626 		'links_rating_image0',
       
   627 		'links_rating_image1',
       
   628 		'links_rating_image2',
       
   629 		'links_rating_image3',
       
   630 		'links_rating_image4',
       
   631 		'links_rating_image5',
       
   632 		'links_rating_image6',
       
   633 		'links_rating_image7',
       
   634 		'links_rating_image8',
       
   635 		'links_rating_image9',
       
   636 		'links_recently_updated_time',
       
   637 		'links_recently_updated_prepend',
       
   638 		'links_recently_updated_append',
       
   639 		'weblogs_cacheminutes',
       
   640 		'comment_allowed_tags',
       
   641 		'search_engine_friendly_urls',
       
   642 		'default_geourl_lat',
       
   643 		'default_geourl_lon',
       
   644 		'use_default_geourl',
       
   645 		'weblogs_xml_url',
       
   646 		'new_users_can_blog',
       
   647 		'_wpnonce',
       
   648 		'_wp_http_referer',
       
   649 		'Update',
       
   650 		'action',
       
   651 		'rich_editing',
       
   652 		'autosave_interval',
       
   653 		'deactivated_plugins',
       
   654 		'can_compress_scripts',
       
   655 		'page_uris',
       
   656 		'update_core',
       
   657 		'update_plugins',
       
   658 		'update_themes',
       
   659 		'doing_cron',
       
   660 		'random_seed',
       
   661 		'rss_excerpt_length',
       
   662 		'secret',
       
   663 		'use_linksupdate',
       
   664 		'default_comment_status_page',
       
   665 		'wporg_popular_tags',
       
   666 		'what_to_show',
       
   667 		'rss_language',
       
   668 		'language',
       
   669 		'enable_xmlrpc',
       
   670 		'enable_app',
       
   671 		'embed_autourls',
       
   672 		'default_post_edit_rows',
       
   673 		'gzipcompression',
       
   674 		'advanced_edit',
   586 	);
   675 	);
   587 	foreach ( $unusedoptions as $option )
   676 	foreach ( $unusedoptions as $option ) {
   588 		delete_option($option);
   677 		delete_option( $option );
       
   678 	}
   589 
   679 
   590 	// Delete obsolete magpie stuff.
   680 	// Delete obsolete magpie stuff.
   591 	$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
   681 	$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" );
   592 
   682 
   593 	// Clear expired transients
   683 	// Clear expired transients
   594 	delete_expired_transients( true );
   684 	delete_expired_transients( true );
   595 }
   685 }
   596 
   686 
   616  * @since 2.0.0
   706  * @since 2.0.0
   617  */
   707  */
   618 function populate_roles_160() {
   708 function populate_roles_160() {
   619 	// Add roles
   709 	// Add roles
   620 
   710 
   621 	// Dummy gettext calls to get strings in the catalog.
   711 	add_role( 'administrator', 'Administrator' );
   622 	/* translators: user role */
   712 	add_role( 'editor', 'Editor' );
   623 	_x('Administrator', 'User role');
   713 	add_role( 'author', 'Author' );
   624 	/* translators: user role */
   714 	add_role( 'contributor', 'Contributor' );
   625 	_x('Editor', 'User role');
   715 	add_role( 'subscriber', 'Subscriber' );
   626 	/* translators: user role */
       
   627 	_x('Author', 'User role');
       
   628 	/* translators: user role */
       
   629 	_x('Contributor', 'User role');
       
   630 	/* translators: user role */
       
   631 	_x('Subscriber', 'User role');
       
   632 
       
   633 	add_role('administrator', 'Administrator');
       
   634 	add_role('editor', 'Editor');
       
   635 	add_role('author', 'Author');
       
   636 	add_role('contributor', 'Contributor');
       
   637 	add_role('subscriber', 'Subscriber');
       
   638 
   716 
   639 	// Add caps for Administrator role
   717 	// Add caps for Administrator role
   640 	$role = get_role('administrator');
   718 	$role = get_role( 'administrator' );
   641 	$role->add_cap('switch_themes');
   719 	$role->add_cap( 'switch_themes' );
   642 	$role->add_cap('edit_themes');
   720 	$role->add_cap( 'edit_themes' );
   643 	$role->add_cap('activate_plugins');
   721 	$role->add_cap( 'activate_plugins' );
   644 	$role->add_cap('edit_plugins');
   722 	$role->add_cap( 'edit_plugins' );
   645 	$role->add_cap('edit_users');
   723 	$role->add_cap( 'edit_users' );
   646 	$role->add_cap('edit_files');
   724 	$role->add_cap( 'edit_files' );
   647 	$role->add_cap('manage_options');
   725 	$role->add_cap( 'manage_options' );
   648 	$role->add_cap('moderate_comments');
   726 	$role->add_cap( 'moderate_comments' );
   649 	$role->add_cap('manage_categories');
   727 	$role->add_cap( 'manage_categories' );
   650 	$role->add_cap('manage_links');
   728 	$role->add_cap( 'manage_links' );
   651 	$role->add_cap('upload_files');
   729 	$role->add_cap( 'upload_files' );
   652 	$role->add_cap('import');
   730 	$role->add_cap( 'import' );
   653 	$role->add_cap('unfiltered_html');
   731 	$role->add_cap( 'unfiltered_html' );
   654 	$role->add_cap('edit_posts');
   732 	$role->add_cap( 'edit_posts' );
   655 	$role->add_cap('edit_others_posts');
   733 	$role->add_cap( 'edit_others_posts' );
   656 	$role->add_cap('edit_published_posts');
   734 	$role->add_cap( 'edit_published_posts' );
   657 	$role->add_cap('publish_posts');
   735 	$role->add_cap( 'publish_posts' );
   658 	$role->add_cap('edit_pages');
   736 	$role->add_cap( 'edit_pages' );
   659 	$role->add_cap('read');
   737 	$role->add_cap( 'read' );
   660 	$role->add_cap('level_10');
   738 	$role->add_cap( 'level_10' );
   661 	$role->add_cap('level_9');
   739 	$role->add_cap( 'level_9' );
   662 	$role->add_cap('level_8');
   740 	$role->add_cap( 'level_8' );
   663 	$role->add_cap('level_7');
   741 	$role->add_cap( 'level_7' );
   664 	$role->add_cap('level_6');
   742 	$role->add_cap( 'level_6' );
   665 	$role->add_cap('level_5');
   743 	$role->add_cap( 'level_5' );
   666 	$role->add_cap('level_4');
   744 	$role->add_cap( 'level_4' );
   667 	$role->add_cap('level_3');
   745 	$role->add_cap( 'level_3' );
   668 	$role->add_cap('level_2');
   746 	$role->add_cap( 'level_2' );
   669 	$role->add_cap('level_1');
   747 	$role->add_cap( 'level_1' );
   670 	$role->add_cap('level_0');
   748 	$role->add_cap( 'level_0' );
   671 
   749 
   672 	// Add caps for Editor role
   750 	// Add caps for Editor role
   673 	$role = get_role('editor');
   751 	$role = get_role( 'editor' );
   674 	$role->add_cap('moderate_comments');
   752 	$role->add_cap( 'moderate_comments' );
   675 	$role->add_cap('manage_categories');
   753 	$role->add_cap( 'manage_categories' );
   676 	$role->add_cap('manage_links');
   754 	$role->add_cap( 'manage_links' );
   677 	$role->add_cap('upload_files');
   755 	$role->add_cap( 'upload_files' );
   678 	$role->add_cap('unfiltered_html');
   756 	$role->add_cap( 'unfiltered_html' );
   679 	$role->add_cap('edit_posts');
   757 	$role->add_cap( 'edit_posts' );
   680 	$role->add_cap('edit_others_posts');
   758 	$role->add_cap( 'edit_others_posts' );
   681 	$role->add_cap('edit_published_posts');
   759 	$role->add_cap( 'edit_published_posts' );
   682 	$role->add_cap('publish_posts');
   760 	$role->add_cap( 'publish_posts' );
   683 	$role->add_cap('edit_pages');
   761 	$role->add_cap( 'edit_pages' );
   684 	$role->add_cap('read');
   762 	$role->add_cap( 'read' );
   685 	$role->add_cap('level_7');
   763 	$role->add_cap( 'level_7' );
   686 	$role->add_cap('level_6');
   764 	$role->add_cap( 'level_6' );
   687 	$role->add_cap('level_5');
   765 	$role->add_cap( 'level_5' );
   688 	$role->add_cap('level_4');
   766 	$role->add_cap( 'level_4' );
   689 	$role->add_cap('level_3');
   767 	$role->add_cap( 'level_3' );
   690 	$role->add_cap('level_2');
   768 	$role->add_cap( 'level_2' );
   691 	$role->add_cap('level_1');
   769 	$role->add_cap( 'level_1' );
   692 	$role->add_cap('level_0');
   770 	$role->add_cap( 'level_0' );
   693 
   771 
   694 	// Add caps for Author role
   772 	// Add caps for Author role
   695 	$role = get_role('author');
   773 	$role = get_role( 'author' );
   696 	$role->add_cap('upload_files');
   774 	$role->add_cap( 'upload_files' );
   697 	$role->add_cap('edit_posts');
   775 	$role->add_cap( 'edit_posts' );
   698 	$role->add_cap('edit_published_posts');
   776 	$role->add_cap( 'edit_published_posts' );
   699 	$role->add_cap('publish_posts');
   777 	$role->add_cap( 'publish_posts' );
   700 	$role->add_cap('read');
   778 	$role->add_cap( 'read' );
   701 	$role->add_cap('level_2');
   779 	$role->add_cap( 'level_2' );
   702 	$role->add_cap('level_1');
   780 	$role->add_cap( 'level_1' );
   703 	$role->add_cap('level_0');
   781 	$role->add_cap( 'level_0' );
   704 
   782 
   705 	// Add caps for Contributor role
   783 	// Add caps for Contributor role
   706 	$role = get_role('contributor');
   784 	$role = get_role( 'contributor' );
   707 	$role->add_cap('edit_posts');
   785 	$role->add_cap( 'edit_posts' );
   708 	$role->add_cap('read');
   786 	$role->add_cap( 'read' );
   709 	$role->add_cap('level_1');
   787 	$role->add_cap( 'level_1' );
   710 	$role->add_cap('level_0');
   788 	$role->add_cap( 'level_0' );
   711 
   789 
   712 	// Add caps for Subscriber role
   790 	// Add caps for Subscriber role
   713 	$role = get_role('subscriber');
   791 	$role = get_role( 'subscriber' );
   714 	$role->add_cap('read');
   792 	$role->add_cap( 'read' );
   715 	$role->add_cap('level_0');
   793 	$role->add_cap( 'level_0' );
   716 }
   794 }
   717 
   795 
   718 /**
   796 /**
   719  * Create and modify WordPress roles for WordPress 2.1.
   797  * Create and modify WordPress roles for WordPress 2.1.
   720  *
   798  *
   721  * @since 2.1.0
   799  * @since 2.1.0
   722  */
   800  */
   723 function populate_roles_210() {
   801 function populate_roles_210() {
   724 	$roles = array('administrator', 'editor');
   802 	$roles = array( 'administrator', 'editor' );
   725 	foreach ($roles as $role) {
   803 	foreach ( $roles as $role ) {
   726 		$role = get_role($role);
   804 		$role = get_role( $role );
   727 		if ( empty($role) )
   805 		if ( empty( $role ) ) {
   728 			continue;
   806 			continue;
   729 
   807 		}
   730 		$role->add_cap('edit_others_pages');
   808 
   731 		$role->add_cap('edit_published_pages');
   809 		$role->add_cap( 'edit_others_pages' );
   732 		$role->add_cap('publish_pages');
   810 		$role->add_cap( 'edit_published_pages' );
   733 		$role->add_cap('delete_pages');
   811 		$role->add_cap( 'publish_pages' );
   734 		$role->add_cap('delete_others_pages');
   812 		$role->add_cap( 'delete_pages' );
   735 		$role->add_cap('delete_published_pages');
   813 		$role->add_cap( 'delete_others_pages' );
   736 		$role->add_cap('delete_posts');
   814 		$role->add_cap( 'delete_published_pages' );
   737 		$role->add_cap('delete_others_posts');
   815 		$role->add_cap( 'delete_posts' );
   738 		$role->add_cap('delete_published_posts');
   816 		$role->add_cap( 'delete_others_posts' );
   739 		$role->add_cap('delete_private_posts');
   817 		$role->add_cap( 'delete_published_posts' );
   740 		$role->add_cap('edit_private_posts');
   818 		$role->add_cap( 'delete_private_posts' );
   741 		$role->add_cap('read_private_posts');
   819 		$role->add_cap( 'edit_private_posts' );
   742 		$role->add_cap('delete_private_pages');
   820 		$role->add_cap( 'read_private_posts' );
   743 		$role->add_cap('edit_private_pages');
   821 		$role->add_cap( 'delete_private_pages' );
   744 		$role->add_cap('read_private_pages');
   822 		$role->add_cap( 'edit_private_pages' );
   745 	}
   823 		$role->add_cap( 'read_private_pages' );
   746 
   824 	}
   747 	$role = get_role('administrator');
   825 
   748 	if ( ! empty($role) ) {
   826 	$role = get_role( 'administrator' );
   749 		$role->add_cap('delete_users');
   827 	if ( ! empty( $role ) ) {
   750 		$role->add_cap('create_users');
   828 		$role->add_cap( 'delete_users' );
   751 	}
   829 		$role->add_cap( 'create_users' );
   752 
   830 	}
   753 	$role = get_role('author');
   831 
   754 	if ( ! empty($role) ) {
   832 	$role = get_role( 'author' );
   755 		$role->add_cap('delete_posts');
   833 	if ( ! empty( $role ) ) {
   756 		$role->add_cap('delete_published_posts');
   834 		$role->add_cap( 'delete_posts' );
   757 	}
   835 		$role->add_cap( 'delete_published_posts' );
   758 
   836 	}
   759 	$role = get_role('contributor');
   837 
   760 	if ( ! empty($role) ) {
   838 	$role = get_role( 'contributor' );
   761 		$role->add_cap('delete_posts');
   839 	if ( ! empty( $role ) ) {
       
   840 		$role->add_cap( 'delete_posts' );
   762 	}
   841 	}
   763 }
   842 }
   764 
   843 
   765 /**
   844 /**
   766  * Create and modify WordPress roles for WordPress 2.3.
   845  * Create and modify WordPress roles for WordPress 2.3.
   768  * @since 2.3.0
   847  * @since 2.3.0
   769  */
   848  */
   770 function populate_roles_230() {
   849 function populate_roles_230() {
   771 	$role = get_role( 'administrator' );
   850 	$role = get_role( 'administrator' );
   772 
   851 
   773 	if ( !empty( $role ) ) {
   852 	if ( ! empty( $role ) ) {
   774 		$role->add_cap( 'unfiltered_upload' );
   853 		$role->add_cap( 'unfiltered_upload' );
   775 	}
   854 	}
   776 }
   855 }
   777 
   856 
   778 /**
   857 /**
   781  * @since 2.5.0
   860  * @since 2.5.0
   782  */
   861  */
   783 function populate_roles_250() {
   862 function populate_roles_250() {
   784 	$role = get_role( 'administrator' );
   863 	$role = get_role( 'administrator' );
   785 
   864 
   786 	if ( !empty( $role ) ) {
   865 	if ( ! empty( $role ) ) {
   787 		$role->add_cap( 'edit_dashboard' );
   866 		$role->add_cap( 'edit_dashboard' );
   788 	}
   867 	}
   789 }
   868 }
   790 
   869 
   791 /**
   870 /**
   794  * @since 2.6.0
   873  * @since 2.6.0
   795  */
   874  */
   796 function populate_roles_260() {
   875 function populate_roles_260() {
   797 	$role = get_role( 'administrator' );
   876 	$role = get_role( 'administrator' );
   798 
   877 
   799 	if ( !empty( $role ) ) {
   878 	if ( ! empty( $role ) ) {
   800 		$role->add_cap( 'update_plugins' );
   879 		$role->add_cap( 'update_plugins' );
   801 		$role->add_cap( 'delete_plugins' );
   880 		$role->add_cap( 'delete_plugins' );
   802 	}
   881 	}
   803 }
   882 }
   804 
   883 
   808  * @since 2.7.0
   887  * @since 2.7.0
   809  */
   888  */
   810 function populate_roles_270() {
   889 function populate_roles_270() {
   811 	$role = get_role( 'administrator' );
   890 	$role = get_role( 'administrator' );
   812 
   891 
   813 	if ( !empty( $role ) ) {
   892 	if ( ! empty( $role ) ) {
   814 		$role->add_cap( 'install_plugins' );
   893 		$role->add_cap( 'install_plugins' );
   815 		$role->add_cap( 'update_themes' );
   894 		$role->add_cap( 'update_themes' );
   816 	}
   895 	}
   817 }
   896 }
   818 
   897 
   822  * @since 2.8.0
   901  * @since 2.8.0
   823  */
   902  */
   824 function populate_roles_280() {
   903 function populate_roles_280() {
   825 	$role = get_role( 'administrator' );
   904 	$role = get_role( 'administrator' );
   826 
   905 
   827 	if ( !empty( $role ) ) {
   906 	if ( ! empty( $role ) ) {
   828 		$role->add_cap( 'install_themes' );
   907 		$role->add_cap( 'install_themes' );
   829 	}
   908 	}
   830 }
   909 }
   831 
   910 
   832 /**
   911 /**
   835  * @since 3.0.0
   914  * @since 3.0.0
   836  */
   915  */
   837 function populate_roles_300() {
   916 function populate_roles_300() {
   838 	$role = get_role( 'administrator' );
   917 	$role = get_role( 'administrator' );
   839 
   918 
   840 	if ( !empty( $role ) ) {
   919 	if ( ! empty( $role ) ) {
   841 		$role->add_cap( 'update_core' );
   920 		$role->add_cap( 'update_core' );
   842 		$role->add_cap( 'list_users' );
   921 		$role->add_cap( 'list_users' );
   843 		$role->add_cap( 'remove_users' );
   922 		$role->add_cap( 'remove_users' );
   844 		$role->add_cap( 'promote_users' );
   923 		$role->add_cap( 'promote_users' );
   845 		$role->add_cap( 'edit_theme_options' );
   924 		$role->add_cap( 'edit_theme_options' );
   846 		$role->add_cap( 'delete_themes' );
   925 		$role->add_cap( 'delete_themes' );
   847 		$role->add_cap( 'export' );
   926 		$role->add_cap( 'export' );
   848 	}
   927 	}
   849 }
   928 }
   850 
   929 
   851 if ( !function_exists( 'install_network' ) ) :
   930 if ( ! function_exists( 'install_network' ) ) :
   852 /**
   931 	/**
   853  * Install Network.
   932 	 * Install Network.
   854  *
   933 	 *
   855  * @since 3.0.0
   934 	 * @since 3.0.0
   856  */
   935 	 */
   857 function install_network() {
   936 	function install_network() {
   858 	if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
   937 		if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) {
   859 		define( 'WP_INSTALLING_NETWORK', true );
   938 			define( 'WP_INSTALLING_NETWORK', true );
   860 
   939 		}
   861 	dbDelta( wp_get_db_schema( 'global' ) );
   940 
   862 }
   941 		dbDelta( wp_get_db_schema( 'global' ) );
       
   942 	}
   863 endif;
   943 endif;
   864 
   944 
   865 /**
   945 /**
   866  * Populate network settings.
   946  * Populate network settings.
   867  *
   947  *
   868  * @since 3.0.0
   948  * @since 3.0.0
   869  *
   949  *
   870  * @global wpdb       $wpdb
   950  * @global wpdb       $wpdb
   871  * @global object     $current_site
   951  * @global object     $current_site
   872  * @global int        $wp_db_version
       
   873  * @global WP_Rewrite $wp_rewrite
   952  * @global WP_Rewrite $wp_rewrite
   874  *
   953  *
   875  * @param int    $network_id        ID of network to populate.
   954  * @param int    $network_id        ID of network to populate.
   876  * @param string $domain            The domain name for the network (eg. "example.com").
   955  * @param string $domain            The domain name for the network (eg. "example.com").
   877  * @param string $email             Email address for the network administrator.
   956  * @param string $email             Email address for the network administrator.
   881  *                                  Default false, meaning the network is a subdirectory installation.
   960  *                                  Default false, meaning the network is a subdirectory installation.
   882  * @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful,
   961  * @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful,
   883  *                       so the error code must be checked) or failure.
   962  *                       so the error code must be checked) or failure.
   884  */
   963  */
   885 function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
   964 function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
   886 	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
   965 	global $wpdb, $current_site, $wp_rewrite;
   887 
   966 
   888 	$errors = new WP_Error();
   967 	$errors = new WP_Error();
   889 	if ( '' == $domain )
   968 	if ( '' == $domain ) {
   890 		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
   969 		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
   891 	if ( '' == $site_name )
   970 	}
       
   971 	if ( '' == $site_name ) {
   892 		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
   972 		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
       
   973 	}
   893 
   974 
   894 	// Check for network collision.
   975 	// Check for network collision.
   895 	$network_exists = false;
   976 	$network_exists = false;
   896 	if ( is_multisite() ) {
   977 	if ( is_multisite() ) {
   897 		if ( get_network( (int) $network_id ) ) {
   978 		if ( get_network( (int) $network_id ) ) {
   901 		if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) {
   982 		if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) {
   902 			$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
   983 			$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
   903 		}
   984 		}
   904 	}
   985 	}
   905 
   986 
   906 	if ( ! is_email( $email ) )
   987 	if ( ! is_email( $email ) ) {
   907 		$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
   988 		$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
   908 
   989 	}
   909 	if ( $errors->get_error_code() )
   990 
       
   991 	if ( $errors->has_errors() ) {
   910 		return $errors;
   992 		return $errors;
       
   993 	}
       
   994 
       
   995 	if ( 1 == $network_id ) {
       
   996 		$wpdb->insert(
       
   997 			$wpdb->site,
       
   998 			array(
       
   999 				'domain' => $domain,
       
  1000 				'path'   => $path,
       
  1001 			)
       
  1002 		);
       
  1003 		$network_id = $wpdb->insert_id;
       
  1004 	} else {
       
  1005 		$wpdb->insert(
       
  1006 			$wpdb->site,
       
  1007 			array(
       
  1008 				'domain' => $domain,
       
  1009 				'path'   => $path,
       
  1010 				'id'     => $network_id,
       
  1011 			)
       
  1012 		);
       
  1013 	}
       
  1014 
       
  1015 	populate_network_meta(
       
  1016 		$network_id,
       
  1017 		array(
       
  1018 			'admin_email'       => $email,
       
  1019 			'site_name'         => $site_name,
       
  1020 			'subdomain_install' => $subdomain_install,
       
  1021 		)
       
  1022 	);
       
  1023 
       
  1024 	$site_user = get_userdata( (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", 'admin_user_id', $network_id ) ) );
       
  1025 
       
  1026 	/*
       
  1027 	 * When upgrading from single to multisite, assume the current site will
       
  1028 	 * become the main site of the network. When using populate_network()
       
  1029 	 * to create another network in an existing multisite environment, skip
       
  1030 	 * these steps since the main site of the new network has not yet been
       
  1031 	 * created.
       
  1032 	 */
       
  1033 	if ( ! is_multisite() ) {
       
  1034 		$current_site            = new stdClass;
       
  1035 		$current_site->domain    = $domain;
       
  1036 		$current_site->path      = $path;
       
  1037 		$current_site->site_name = ucfirst( $domain );
       
  1038 		$wpdb->insert(
       
  1039 			$wpdb->blogs,
       
  1040 			array(
       
  1041 				'site_id'    => $network_id,
       
  1042 				'blog_id'    => 1,
       
  1043 				'domain'     => $domain,
       
  1044 				'path'       => $path,
       
  1045 				'registered' => current_time( 'mysql' ),
       
  1046 			)
       
  1047 		);
       
  1048 		$current_site->blog_id = $wpdb->insert_id;
       
  1049 		update_user_meta( $site_user->ID, 'source_domain', $domain );
       
  1050 		update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id );
       
  1051 
       
  1052 		if ( $subdomain_install ) {
       
  1053 			$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
       
  1054 		} else {
       
  1055 			$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
       
  1056 		}
       
  1057 
       
  1058 		flush_rewrite_rules();
       
  1059 
       
  1060 		if ( ! $subdomain_install ) {
       
  1061 			return true;
       
  1062 		}
       
  1063 
       
  1064 		$vhost_ok = false;
       
  1065 		$errstr   = '';
       
  1066 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
       
  1067 		$page     = wp_remote_get(
       
  1068 			'http://' . $hostname,
       
  1069 			array(
       
  1070 				'timeout'     => 5,
       
  1071 				'httpversion' => '1.1',
       
  1072 			)
       
  1073 		);
       
  1074 		if ( is_wp_error( $page ) ) {
       
  1075 			$errstr = $page->get_error_message();
       
  1076 		} elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) {
       
  1077 				$vhost_ok = true;
       
  1078 		}
       
  1079 
       
  1080 		if ( ! $vhost_ok ) {
       
  1081 			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
       
  1082 
       
  1083 			$msg .= '<p>' . sprintf(
       
  1084 				/* translators: %s: host name */
       
  1085 				__( 'The installer attempted to contact a random hostname (%s) on your domain.' ),
       
  1086 				'<code>' . $hostname . '</code>'
       
  1087 			);
       
  1088 			if ( ! empty( $errstr ) ) {
       
  1089 				/* translators: %s: error message */
       
  1090 				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
       
  1091 			}
       
  1092 			$msg .= '</p>';
       
  1093 
       
  1094 			$msg .= '<p>' . sprintf(
       
  1095 				/* translators: %s: asterisk symbol (*) */
       
  1096 				__( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.' ),
       
  1097 				'<code>*</code>'
       
  1098 			) . '</p>';
       
  1099 
       
  1100 			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
       
  1101 
       
  1102 			return new WP_Error( 'no_wildcard_dns', $msg );
       
  1103 		}
       
  1104 	}
       
  1105 
       
  1106 	return true;
       
  1107 }
       
  1108 
       
  1109 /**
       
  1110  * Creates WordPress network meta and sets the default values.
       
  1111  *
       
  1112  * @since 5.1.0
       
  1113  *
       
  1114  * @global wpdb $wpdb          WordPress database abstraction object.
       
  1115  * @global int  $wp_db_version WordPress database version.
       
  1116  *
       
  1117  * @param int   $network_id Network ID to populate meta for.
       
  1118  * @param array $meta       Optional. Custom meta $key => $value pairs to use. Default empty array.
       
  1119  */
       
  1120 function populate_network_meta( $network_id, array $meta = array() ) {
       
  1121 	global $wpdb, $wp_db_version;
       
  1122 
       
  1123 	$network_id = (int) $network_id;
       
  1124 
       
  1125 	$email             = ! empty( $meta['admin_email'] ) ? $meta['admin_email'] : '';
       
  1126 	$subdomain_install = isset( $meta['subdomain_install'] ) ? (int) $meta['subdomain_install'] : 0;
   911 
  1127 
   912 	// If a user with the provided email does not exist, default to the current user as the new network admin.
  1128 	// If a user with the provided email does not exist, default to the current user as the new network admin.
   913 	$site_user = get_user_by( 'email', $email );
  1129 	$site_user = ! empty( $email ) ? get_user_by( 'email', $email ) : false;
   914 	if ( false === $site_user ) {
  1130 	if ( false === $site_user ) {
   915 		$site_user = wp_get_current_user();
  1131 		$site_user = wp_get_current_user();
   916 	}
  1132 	}
   917 
  1133 
   918 	// Set up site tables.
  1134 	if ( empty( $email ) ) {
   919 	$template = get_option( 'template' );
  1135 		$email = $site_user->user_email;
   920 	$stylesheet = get_option( 'stylesheet' );
  1136 	}
       
  1137 
       
  1138 	$template       = get_option( 'template' );
       
  1139 	$stylesheet     = get_option( 'stylesheet' );
   921 	$allowed_themes = array( $stylesheet => true );
  1140 	$allowed_themes = array( $stylesheet => true );
   922 
  1141 
   923 	if ( $template != $stylesheet ) {
  1142 	if ( $template != $stylesheet ) {
   924 		$allowed_themes[ $template ] = true;
  1143 		$allowed_themes[ $template ] = true;
   925 	}
  1144 	}
   928 		$allowed_themes[ WP_DEFAULT_THEME ] = true;
  1147 		$allowed_themes[ WP_DEFAULT_THEME ] = true;
   929 	}
  1148 	}
   930 
  1149 
   931 	// If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme.
  1150 	// If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme.
   932 	if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) {
  1151 	if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) {
   933 		if ( $core_default = WP_Theme::get_core_default_theme() ) {
  1152 		$core_default = WP_Theme::get_core_default_theme();
       
  1153 		if ( $core_default ) {
   934 			$allowed_themes[ $core_default->get_stylesheet() ] = true;
  1154 			$allowed_themes[ $core_default->get_stylesheet() ] = true;
   935 		}
  1155 		}
   936 	}
  1156 	}
   937 
  1157 
   938 	if ( 1 == $network_id ) {
       
   939 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
       
   940 		$network_id = $wpdb->insert_id;
       
   941 	} else {
       
   942 		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
       
   943 	}
       
   944 
       
   945 	wp_cache_delete( 'networks_have_paths', 'site-options' );
  1158 	wp_cache_delete( 'networks_have_paths', 'site-options' );
   946 
  1159 
   947 	if ( !is_multisite() ) {
  1160 	if ( ! is_multisite() ) {
   948 		$site_admins = array( $site_user->user_login );
  1161 		$site_admins = array( $site_user->user_login );
   949 		$users = get_users( array(
  1162 		$users       = get_users(
   950 			'fields' => array( 'user_login' ),
  1163 			array(
   951 			'role'   => 'administrator',
  1164 				'fields' => array( 'user_login' ),
   952 		) );
  1165 				'role'   => 'administrator',
       
  1166 			)
       
  1167 		);
   953 		if ( $users ) {
  1168 		if ( $users ) {
   954 			foreach ( $users as $user ) {
  1169 			foreach ( $users as $user ) {
   955 				$site_admins[] = $user->user_login;
  1170 				$site_admins[] = $user->user_login;
   956 			}
  1171 			}
   957 
  1172 
   960 	} else {
  1175 	} else {
   961 		$site_admins = get_site_option( 'site_admins' );
  1176 		$site_admins = get_site_option( 'site_admins' );
   962 	}
  1177 	}
   963 
  1178 
   964 	/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
  1179 	/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
   965 	$welcome_email = __( 'Howdy USERNAME,
  1180 	$welcome_email = __(
       
  1181 		'Howdy USERNAME,
   966 
  1182 
   967 Your new SITE_NAME site has been successfully set up at:
  1183 Your new SITE_NAME site has been successfully set up at:
   968 BLOG_URL
  1184 BLOG_URL
   969 
  1185 
   970 You can log in to the administrator account with the following information:
  1186 You can log in to the administrator account with the following information:
   973 Password: PASSWORD
  1189 Password: PASSWORD
   974 Log in here: BLOG_URLwp-login.php
  1190 Log in here: BLOG_URLwp-login.php
   975 
  1191 
   976 We hope you enjoy your new site. Thanks!
  1192 We hope you enjoy your new site. Thanks!
   977 
  1193 
   978 --The Team @ SITE_NAME' );
  1194 --The Team @ SITE_NAME'
   979 
  1195 	);
   980 	$misc_exts = array(
  1196 
       
  1197 	$misc_exts        = array(
   981 		// Images.
  1198 		// Images.
   982 		'jpg', 'jpeg', 'png', 'gif',
  1199 		'jpg',
       
  1200 		'jpeg',
       
  1201 		'png',
       
  1202 		'gif',
   983 		// Video.
  1203 		// Video.
   984 		'mov', 'avi', 'mpg', '3gp', '3g2',
  1204 		'mov',
       
  1205 		'avi',
       
  1206 		'mpg',
       
  1207 		'3gp',
       
  1208 		'3g2',
   985 		// "audio".
  1209 		// "audio".
   986 		'midi', 'mid',
  1210 		'midi',
       
  1211 		'mid',
   987 		// Miscellaneous.
  1212 		// Miscellaneous.
   988 		'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key',
  1213 		'pdf',
       
  1214 		'doc',
       
  1215 		'ppt',
       
  1216 		'odt',
       
  1217 		'pptx',
       
  1218 		'docx',
       
  1219 		'pps',
       
  1220 		'ppsx',
       
  1221 		'xls',
       
  1222 		'xlsx',
       
  1223 		'key',
   989 	);
  1224 	);
   990 	$audio_exts = wp_get_audio_extensions();
  1225 	$audio_exts       = wp_get_audio_extensions();
   991 	$video_exts = wp_get_video_extensions();
  1226 	$video_exts       = wp_get_video_extensions();
   992 	$upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) );
  1227 	$upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) );
   993 
  1228 
   994 	$sitemeta = array(
  1229 	$sitemeta = array(
   995 		'site_name' => $site_name,
  1230 		'site_name'                   => __( 'My Network' ),
   996 		'admin_email' => $email,
  1231 		'admin_email'                 => $email,
   997 		'admin_user_id' => $site_user->ID,
  1232 		'admin_user_id'               => $site_user->ID,
   998 		'registration' => 'none',
  1233 		'registration'                => 'none',
   999 		'upload_filetypes' => implode( ' ', $upload_filetypes ),
  1234 		'upload_filetypes'            => implode( ' ', $upload_filetypes ),
  1000 		'blog_upload_space' => 100,
  1235 		'blog_upload_space'           => 100,
  1001 		'fileupload_maxk' => 1500,
  1236 		'fileupload_maxk'             => 1500,
  1002 		'site_admins' => $site_admins,
  1237 		'site_admins'                 => $site_admins,
  1003 		'allowedthemes' => $allowed_themes,
  1238 		'allowedthemes'               => $allowed_themes,
  1004 		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
  1239 		'illegal_names'               => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
  1005 		'wpmu_upgrade_site' => $wp_db_version,
  1240 		'wpmu_upgrade_site'           => $wp_db_version,
  1006 		'welcome_email' => $welcome_email,
  1241 		'welcome_email'               => $welcome_email,
  1007 		/* translators: %s: site link */
  1242 		/* translators: %s: site link */
  1008 		'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ),
  1243 		'first_post'                  => __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ),
  1009 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
  1244 		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
  1010 		'siteurl' => get_option( 'siteurl' ) . '/',
  1245 		'siteurl'                     => get_option( 'siteurl' ) . '/',
  1011 		'add_new_users' => '0',
  1246 		'add_new_users'               => '0',
  1012 		'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1',
  1247 		'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1',
  1013 		'subdomain_install' => intval( $subdomain_install ),
  1248 		'subdomain_install'           => $subdomain_install,
  1014 		'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
  1249 		'global_terms_enabled'        => global_terms_enabled() ? '1' : '0',
  1015 		'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
  1250 		'ms_files_rewriting'          => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0',
  1016 		'initial_db_version' => get_option( 'initial_db_version' ),
  1251 		'initial_db_version'          => get_option( 'initial_db_version' ),
  1017 		'active_sitewide_plugins' => array(),
  1252 		'active_sitewide_plugins'     => array(),
  1018 		'WPLANG' => get_locale(),
  1253 		'WPLANG'                      => get_locale(),
  1019 	);
  1254 	);
  1020 	if ( ! $subdomain_install )
  1255 	if ( ! $subdomain_install ) {
  1021 		$sitemeta['illegal_names'][] = 'blog';
  1256 		$sitemeta['illegal_names'][] = 'blog';
       
  1257 	}
       
  1258 
       
  1259 	$sitemeta = wp_parse_args( $meta, $sitemeta );
  1022 
  1260 
  1023 	/**
  1261 	/**
  1024 	 * Filters meta for a network on creation.
  1262 	 * Filters meta for a network on creation.
  1025 	 *
  1263 	 *
  1026 	 * @since 3.7.0
  1264 	 * @since 3.7.0
  1030 	 */
  1268 	 */
  1031 	$sitemeta = apply_filters( 'populate_network_meta', $sitemeta, $network_id );
  1269 	$sitemeta = apply_filters( 'populate_network_meta', $sitemeta, $network_id );
  1032 
  1270 
  1033 	$insert = '';
  1271 	$insert = '';
  1034 	foreach ( $sitemeta as $meta_key => $meta_value ) {
  1272 	foreach ( $sitemeta as $meta_key => $meta_value ) {
  1035 		if ( is_array( $meta_value ) )
  1273 		if ( is_array( $meta_value ) ) {
  1036 			$meta_value = serialize( $meta_value );
  1274 			$meta_value = serialize( $meta_value );
  1037 		if ( !empty( $insert ) )
  1275 		}
       
  1276 		if ( ! empty( $insert ) ) {
  1038 			$insert .= ', ';
  1277 			$insert .= ', ';
  1039 		$insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value );
  1278 		}
  1040 	}
  1279 		$insert .= $wpdb->prepare( '( %d, %s, %s)', $network_id, $meta_key, $meta_value );
  1041 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
  1280 	}
  1042 
  1281 	$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
  1043 	/*
  1282 }
  1044 	 * When upgrading from single to multisite, assume the current site will
  1283 
  1045 	 * become the main site of the network. When using populate_network()
  1284 /**
  1046 	 * to create another network in an existing multisite environment, skip
  1285  * Creates WordPress site meta and sets the default values.
  1047 	 * these steps since the main site of the new network has not yet been
  1286  *
  1048 	 * created.
  1287  * @since 5.1.0
       
  1288  *
       
  1289  * @global wpdb $wpdb WordPress database abstraction object.
       
  1290  *
       
  1291  * @param int   $site_id Site ID to populate meta for.
       
  1292  * @param array $meta    Optional. Custom meta $key => $value pairs to use. Default empty array.
       
  1293  */
       
  1294 function populate_site_meta( $site_id, array $meta = array() ) {
       
  1295 	global $wpdb;
       
  1296 
       
  1297 	$site_id = (int) $site_id;
       
  1298 
       
  1299 	if ( ! is_site_meta_supported() ) {
       
  1300 		return;
       
  1301 	}
       
  1302 
       
  1303 	if ( empty( $meta ) ) {
       
  1304 		return;
       
  1305 	}
       
  1306 
       
  1307 	/**
       
  1308 	 * Filters meta for a site on creation.
       
  1309 	 *
       
  1310 	 * @since 5.2.0
       
  1311 	 *
       
  1312 	 * @param array $meta    Associative array of site meta keys and values to be inserted.
       
  1313 	 * @param int   $site_id ID of site to populate.
  1049 	 */
  1314 	 */
  1050 	if ( ! is_multisite() ) {
  1315 	$site_meta = apply_filters( 'populate_site_meta', $meta, $site_id );
  1051 		$current_site = new stdClass;
  1316 
  1052 		$current_site->domain = $domain;
  1317 	$insert = '';
  1053 		$current_site->path = $path;
  1318 	foreach ( $site_meta as $meta_key => $meta_value ) {
  1054 		$current_site->site_name = ucfirst( $domain );
  1319 		if ( is_array( $meta_value ) ) {
  1055 		$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
  1320 			$meta_value = serialize( $meta_value );
  1056 		$current_site->blog_id = $blog_id = $wpdb->insert_id;
  1321 		}
  1057 		update_user_meta( $site_user->ID, 'source_domain', $domain );
  1322 		if ( ! empty( $insert ) ) {
  1058 		update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
  1323 			$insert .= ', ';
  1059 
  1324 		}
  1060 		if ( $subdomain_install )
  1325 		$insert .= $wpdb->prepare( '( %d, %s, %s)', $site_id, $meta_key, $meta_value );
  1061 			$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
  1326 	}
  1062 		else
  1327 
  1063 			$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
  1328 	$wpdb->query( "INSERT INTO $wpdb->blogmeta ( blog_id, meta_key, meta_value ) VALUES " . $insert ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
  1064 
  1329 
  1065 		flush_rewrite_rules();
  1330 	wp_cache_delete( $site_id, 'blog_meta' );
  1066 
  1331 	wp_cache_set_sites_last_changed();
  1067 		if ( ! $subdomain_install )
       
  1068 			return true;
       
  1069 
       
  1070 		$vhost_ok = false;
       
  1071 		$errstr = '';
       
  1072 		$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
       
  1073 		$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
       
  1074 		if ( is_wp_error( $page ) )
       
  1075 			$errstr = $page->get_error_message();
       
  1076 		elseif ( 200 == wp_remote_retrieve_response_code( $page ) )
       
  1077 				$vhost_ok = true;
       
  1078 
       
  1079 		if ( ! $vhost_ok ) {
       
  1080 			$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
       
  1081 
       
  1082 			$msg .= '<p>' . sprintf(
       
  1083 				/* translators: %s: host name */
       
  1084 				__( 'The installer attempted to contact a random hostname (%s) on your domain.' ),
       
  1085 				'<code>' . $hostname . '</code>'
       
  1086 			);
       
  1087 			if ( ! empty ( $errstr ) ) {
       
  1088 				/* translators: %s: error message */
       
  1089 				$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
       
  1090 			}
       
  1091 			$msg .= '</p>';
       
  1092 
       
  1093 			$msg .= '<p>' . sprintf(
       
  1094 				/* translators: %s: asterisk symbol (*) */
       
  1095 				__( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a %s hostname record pointing at your web server in your DNS configuration tool.' ),
       
  1096 				'<code>*</code>'
       
  1097 			) . '</p>';
       
  1098 
       
  1099 			$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
       
  1100 
       
  1101 			return new WP_Error( 'no_wildcard_dns', $msg );
       
  1102 		}
       
  1103 	}
       
  1104 
       
  1105 	return true;
       
  1106 }
  1332 }