/wp-admin/includes/schema.php

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