author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 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 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* Declare these as global in case schema.php is included from a function. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* @global wpdb $wpdb |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* @global array $wp_queries |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @global string $charset_collate |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
*/ |
0 | 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 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* |
0 | 32 |
* @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* @param int $blog_id Optional. The site ID for which to retrieve SQL. Default is the current site ID. |
0 | 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 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
$charset_collate = $wpdb->get_charset_collate(); |
0 | 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 |
||
5 | 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 |
||
0 | 54 |
// Blog specific tables. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
$blog_tables = "CREATE TABLE $wpdb->termmeta ( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
meta_id bigint(20) unsigned NOT NULL auto_increment, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
term_id bigint(20) unsigned NOT NULL default '0', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
meta_key varchar(255) default NULL, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
meta_value longtext, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
PRIMARY KEY (meta_id), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
KEY term_id (term_id), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
KEY meta_key (meta_key($max_index_length)) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
) $charset_collate; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
CREATE TABLE $wpdb->terms ( |
0 | 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), |
|
5 | 70 |
KEY slug (slug($max_index_length)), |
71 |
KEY name (name($max_index_length)) |
|
0 | 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), |
|
5 | 98 |
KEY meta_key (meta_key($max_index_length)) |
0 | 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), |
|
5 | 120 |
KEY comment_parent (comment_parent), |
121 |
KEY comment_author_email (comment_author_email(10)) |
|
0 | 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, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
option_name varchar(191) NOT NULL default '', |
0 | 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), |
|
5 | 155 |
KEY meta_key (meta_key($max_index_length)) |
0 | 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', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
post_password varchar(255) NOT NULL default '', |
0 | 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), |
|
5 | 182 |
KEY post_name (post_name($max_index_length)), |
0 | 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 '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
user_pass varchar(255) NOT NULL default '', |
0 | 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', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
user_activation_key varchar(255) NOT NULL default '', |
0 | 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), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
KEY user_nicename (user_nicename), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
KEY user_email (user_email) |
0 | 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 '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
user_pass varchar(255) NOT NULL default '', |
0 | 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', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
user_activation_key varchar(255) NOT NULL default '', |
0 | 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), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
KEY user_nicename (user_nicename), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
KEY user_email (user_email) |
0 | 224 |
) $charset_collate;\n"; |
225 |
||
5 | 226 |
// Usermeta. |
0 | 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), |
|
5 | 234 |
KEY meta_key (meta_key($max_index_length)) |
0 | 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), |
|
5 | 282 |
KEY domain (domain(140),path(51)) |
0 | 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), |
|
5 | 290 |
KEY meta_key (meta_key($max_index_length)), |
0 | 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), |
|
5 | 309 |
KEY domain_path (domain(140),path(51)) |
0 | 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; |
|
5 | 324 |
case 'all' : |
0 | 325 |
default: |
326 |
$queries = $global_tables . $blog_tables; |
|
327 |
if ( $is_multisite ) |
|
328 |
$queries .= $ms_global_tables; |
|
329 |
break; |
|
330 |
} |
|
331 |
||
332 |
if ( isset( $old_blog_id ) ) |
|
333 |
$wpdb->set_blog_id( $old_blog_id ); |
|
334 |
||
335 |
return $queries; |
|
336 |
} |
|
337 |
||
338 |
// Populate for back compat. |
|
339 |
$wp_queries = wp_get_db_schema( 'all' ); |
|
340 |
||
341 |
/** |
|
342 |
* Create WordPress options and set the default values. |
|
343 |
* |
|
344 |
* @since 1.5.0 |
|
5 | 345 |
* |
346 |
* @global wpdb $wpdb WordPress database abstraction object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* @global int $wp_db_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
* @global int $wp_current_db_version |
0 | 349 |
*/ |
350 |
function populate_options() { |
|
5 | 351 |
global $wpdb, $wp_db_version, $wp_current_db_version; |
0 | 352 |
|
353 |
$guessurl = wp_guess_url(); |
|
5 | 354 |
/** |
355 |
* Fires before creating WordPress options and populating their default values. |
|
356 |
* |
|
357 |
* @since 2.6.0 |
|
358 |
*/ |
|
359 |
do_action( 'populate_options' ); |
|
0 | 360 |
|
361 |
if ( ini_get('safe_mode') ) { |
|
362 |
// Safe mode can break mkdir() so use a flat structure by default. |
|
363 |
$uploads_use_yearmonth_folders = 0; |
|
364 |
} else { |
|
365 |
$uploads_use_yearmonth_folders = 1; |
|
366 |
} |
|
367 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
// If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
$stylesheet = $template = WP_DEFAULT_THEME; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
$theme = wp_get_theme( WP_DEFAULT_THEME ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
if ( ! $theme->exists() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
$theme = WP_Theme::get_core_default_theme(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
// If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
if ( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
$template = $theme->get_template(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
} |
0 | 380 |
|
381 |
$timezone_string = ''; |
|
382 |
$gmt_offset = 0; |
|
383 |
/* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
or a valid timezone string (America/New_York). See https://secure.php.net/manual/en/timezones.php |
0 | 385 |
for all timezone strings supported by PHP. |
386 |
*/ |
|
387 |
$offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); |
|
388 |
if ( is_numeric( $offset_or_tz ) ) |
|
389 |
$gmt_offset = $offset_or_tz; |
|
390 |
elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) |
|
391 |
$timezone_string = $offset_or_tz; |
|
392 |
||
393 |
$options = array( |
|
394 |
'siteurl' => $guessurl, |
|
5 | 395 |
'home' => $guessurl, |
0 | 396 |
'blogname' => __('My Site'), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
/* translators: site tagline */ |
0 | 398 |
'blogdescription' => __('Just another WordPress site'), |
399 |
'users_can_register' => 0, |
|
400 |
'admin_email' => 'you@example.com', |
|
401 |
/* translators: default start of the week. 0 = Sunday, 1 = Monday */ |
|
402 |
'start_of_week' => _x( '1', 'start of week' ), |
|
403 |
'use_balanceTags' => 0, |
|
404 |
'use_smilies' => 1, |
|
405 |
'require_name_email' => 1, |
|
406 |
'comments_notify' => 1, |
|
407 |
'posts_per_rss' => 10, |
|
408 |
'rss_use_excerpt' => 0, |
|
409 |
'mailserver_url' => 'mail.example.com', |
|
410 |
'mailserver_login' => 'login@example.com', |
|
411 |
'mailserver_pass' => 'password', |
|
412 |
'mailserver_port' => 110, |
|
413 |
'default_category' => 1, |
|
414 |
'default_comment_status' => 'open', |
|
415 |
'default_ping_status' => 'open', |
|
416 |
'default_pingback_flag' => 1, |
|
417 |
'posts_per_page' => 10, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
/* translators: default date format, see https://secure.php.net/date */ |
0 | 419 |
'date_format' => __('F j, Y'), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
/* translators: default time format, see https://secure.php.net/date */ |
0 | 421 |
'time_format' => __('g:i a'), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
/* translators: links last updated date format, see https://secure.php.net/date */ |
0 | 423 |
'links_updated_date_format' => __('F j, Y g:i a'), |
424 |
'comment_moderation' => 0, |
|
425 |
'moderation_notify' => 1, |
|
426 |
'permalink_structure' => '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
'rewrite_rules' => '', |
0 | 428 |
'hack_file' => 0, |
429 |
'blog_charset' => 'UTF-8', |
|
430 |
'moderation_keys' => '', |
|
431 |
'active_plugins' => array(), |
|
432 |
'category_base' => '', |
|
433 |
'ping_sites' => 'http://rpc.pingomatic.com/', |
|
434 |
'comment_max_links' => 2, |
|
435 |
'gmt_offset' => $gmt_offset, |
|
436 |
||
437 |
// 1.5 |
|
438 |
'default_email_category' => 1, |
|
439 |
'recently_edited' => '', |
|
440 |
'template' => $template, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
'stylesheet' => $stylesheet, |
0 | 442 |
'comment_whitelist' => 1, |
443 |
'blacklist_keys' => '', |
|
444 |
'comment_registration' => 0, |
|
445 |
'html_type' => 'text/html', |
|
446 |
||
447 |
// 1.5.1 |
|
448 |
'use_trackback' => 0, |
|
449 |
||
450 |
// 2.0 |
|
451 |
'default_role' => 'subscriber', |
|
452 |
'db_version' => $wp_db_version, |
|
453 |
||
454 |
// 2.0.1 |
|
455 |
'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders, |
|
456 |
'upload_path' => '', |
|
457 |
||
458 |
// 2.1 |
|
459 |
'blog_public' => '1', |
|
460 |
'default_link_category' => 2, |
|
461 |
'show_on_front' => 'posts', |
|
462 |
||
463 |
// 2.2 |
|
464 |
'tag_base' => '', |
|
465 |
||
466 |
// 2.5 |
|
467 |
'show_avatars' => '1', |
|
468 |
'avatar_rating' => 'G', |
|
469 |
'upload_url_path' => '', |
|
470 |
'thumbnail_size_w' => 150, |
|
471 |
'thumbnail_size_h' => 150, |
|
472 |
'thumbnail_crop' => 1, |
|
473 |
'medium_size_w' => 300, |
|
474 |
'medium_size_h' => 300, |
|
475 |
||
476 |
// 2.6 |
|
477 |
'avatar_default' => 'mystery', |
|
478 |
||
479 |
// 2.7 |
|
480 |
'large_size_w' => 1024, |
|
481 |
'large_size_h' => 1024, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
'image_default_link_type' => 'none', |
0 | 483 |
'image_default_size' => '', |
484 |
'image_default_align' => '', |
|
485 |
'close_comments_for_old_posts' => 0, |
|
486 |
'close_comments_days_old' => 14, |
|
487 |
'thread_comments' => 1, |
|
488 |
'thread_comments_depth' => 5, |
|
489 |
'page_comments' => 0, |
|
490 |
'comments_per_page' => 50, |
|
491 |
'default_comments_page' => 'newest', |
|
492 |
'comment_order' => 'asc', |
|
493 |
'sticky_posts' => array(), |
|
494 |
'widget_categories' => array(), |
|
495 |
'widget_text' => array(), |
|
496 |
'widget_rss' => array(), |
|
497 |
'uninstall_plugins' => array(), |
|
498 |
||
499 |
// 2.8 |
|
500 |
'timezone_string' => $timezone_string, |
|
501 |
||
502 |
// 3.0 |
|
503 |
'page_for_posts' => 0, |
|
504 |
'page_on_front' => 0, |
|
505 |
||
506 |
// 3.1 |
|
507 |
'default_post_format' => 0, |
|
508 |
||
509 |
// 3.5 |
|
510 |
'link_manager_enabled' => 0, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
// 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
'finished_splitting_shared_terms' => 1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
'site_icon' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
// 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
'medium_large_size_w' => 768, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
'medium_large_size_h' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
// 4.9.6 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
'wp_page_for_privacy_policy' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
522 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
523 |
// 4.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
'show_comments_cookies_opt_in' => 0, |
0 | 525 |
); |
526 |
||
527 |
// 3.3 |
|
528 |
if ( ! is_multisite() ) { |
|
529 |
$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version |
|
530 |
? $wp_current_db_version : $wp_db_version; |
|
531 |
} |
|
532 |
||
533 |
// 3.0 multisite |
|
534 |
if ( is_multisite() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
/* translators: site tagline */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), get_network()->site_name ); |
0 | 537 |
$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/'; |
538 |
} |
|
539 |
||
540 |
// Set autoload to no for these options |
|
541 |
$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' ); |
|
542 |
||
543 |
$keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; |
|
544 |
$existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); |
|
545 |
||
546 |
$insert = ''; |
|
547 |
foreach ( $options as $option => $value ) { |
|
548 |
if ( in_array($option, $existing_options) ) |
|
549 |
continue; |
|
550 |
if ( in_array($option, $fat_options) ) |
|
551 |
$autoload = 'no'; |
|
552 |
else |
|
553 |
$autoload = 'yes'; |
|
554 |
||
555 |
if ( is_array($value) ) |
|
556 |
$value = serialize($value); |
|
557 |
if ( !empty($insert) ) |
|
558 |
$insert .= ', '; |
|
559 |
$insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload ); |
|
560 |
} |
|
561 |
||
562 |
if ( !empty($insert) ) |
|
563 |
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert); |
|
564 |
||
5 | 565 |
// In case it is set, but blank, update "home". |
0 | 566 |
if ( !__get_option('home') ) update_option('home', $guessurl); |
567 |
||
5 | 568 |
// Delete unused options. |
0 | 569 |
$unusedoptions = array( |
570 |
'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', |
|
571 |
'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', |
|
572 |
'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', |
|
573 |
'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', |
|
574 |
'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', |
|
575 |
'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', |
|
576 |
'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', |
|
577 |
'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', |
|
5 | 578 |
'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append', |
0 | 579 |
'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', |
580 |
'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', |
|
581 |
'_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', |
|
582 |
'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', |
|
583 |
'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', |
|
584 |
'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit' |
0 | 586 |
); |
587 |
foreach ( $unusedoptions as $option ) |
|
588 |
delete_option($option); |
|
589 |
||
5 | 590 |
// Delete obsolete magpie stuff. |
0 | 591 |
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'"); |
592 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
// Clear expired transients |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
delete_expired_transients( true ); |
0 | 595 |
} |
596 |
||
597 |
/** |
|
598 |
* Execute WordPress role creation for the various WordPress versions. |
|
599 |
* |
|
600 |
* @since 2.0.0 |
|
601 |
*/ |
|
602 |
function populate_roles() { |
|
603 |
populate_roles_160(); |
|
604 |
populate_roles_210(); |
|
605 |
populate_roles_230(); |
|
606 |
populate_roles_250(); |
|
607 |
populate_roles_260(); |
|
608 |
populate_roles_270(); |
|
609 |
populate_roles_280(); |
|
610 |
populate_roles_300(); |
|
611 |
} |
|
612 |
||
613 |
/** |
|
614 |
* Create the roles for WordPress 2.0 |
|
615 |
* |
|
616 |
* @since 2.0.0 |
|
617 |
*/ |
|
618 |
function populate_roles_160() { |
|
619 |
// Add roles |
|
620 |
||
621 |
// Dummy gettext calls to get strings in the catalog. |
|
622 |
/* translators: user role */ |
|
623 |
_x('Administrator', 'User role'); |
|
624 |
/* translators: user role */ |
|
625 |
_x('Editor', 'User role'); |
|
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 |
||
639 |
// Add caps for Administrator role |
|
640 |
$role = get_role('administrator'); |
|
641 |
$role->add_cap('switch_themes'); |
|
642 |
$role->add_cap('edit_themes'); |
|
643 |
$role->add_cap('activate_plugins'); |
|
644 |
$role->add_cap('edit_plugins'); |
|
645 |
$role->add_cap('edit_users'); |
|
646 |
$role->add_cap('edit_files'); |
|
647 |
$role->add_cap('manage_options'); |
|
648 |
$role->add_cap('moderate_comments'); |
|
649 |
$role->add_cap('manage_categories'); |
|
650 |
$role->add_cap('manage_links'); |
|
651 |
$role->add_cap('upload_files'); |
|
652 |
$role->add_cap('import'); |
|
653 |
$role->add_cap('unfiltered_html'); |
|
654 |
$role->add_cap('edit_posts'); |
|
655 |
$role->add_cap('edit_others_posts'); |
|
656 |
$role->add_cap('edit_published_posts'); |
|
657 |
$role->add_cap('publish_posts'); |
|
658 |
$role->add_cap('edit_pages'); |
|
659 |
$role->add_cap('read'); |
|
660 |
$role->add_cap('level_10'); |
|
661 |
$role->add_cap('level_9'); |
|
662 |
$role->add_cap('level_8'); |
|
663 |
$role->add_cap('level_7'); |
|
664 |
$role->add_cap('level_6'); |
|
665 |
$role->add_cap('level_5'); |
|
666 |
$role->add_cap('level_4'); |
|
667 |
$role->add_cap('level_3'); |
|
668 |
$role->add_cap('level_2'); |
|
669 |
$role->add_cap('level_1'); |
|
670 |
$role->add_cap('level_0'); |
|
671 |
||
672 |
// Add caps for Editor role |
|
673 |
$role = get_role('editor'); |
|
674 |
$role->add_cap('moderate_comments'); |
|
675 |
$role->add_cap('manage_categories'); |
|
676 |
$role->add_cap('manage_links'); |
|
677 |
$role->add_cap('upload_files'); |
|
678 |
$role->add_cap('unfiltered_html'); |
|
679 |
$role->add_cap('edit_posts'); |
|
680 |
$role->add_cap('edit_others_posts'); |
|
681 |
$role->add_cap('edit_published_posts'); |
|
682 |
$role->add_cap('publish_posts'); |
|
683 |
$role->add_cap('edit_pages'); |
|
684 |
$role->add_cap('read'); |
|
685 |
$role->add_cap('level_7'); |
|
686 |
$role->add_cap('level_6'); |
|
687 |
$role->add_cap('level_5'); |
|
688 |
$role->add_cap('level_4'); |
|
689 |
$role->add_cap('level_3'); |
|
690 |
$role->add_cap('level_2'); |
|
691 |
$role->add_cap('level_1'); |
|
692 |
$role->add_cap('level_0'); |
|
693 |
||
694 |
// Add caps for Author role |
|
695 |
$role = get_role('author'); |
|
696 |
$role->add_cap('upload_files'); |
|
697 |
$role->add_cap('edit_posts'); |
|
698 |
$role->add_cap('edit_published_posts'); |
|
699 |
$role->add_cap('publish_posts'); |
|
700 |
$role->add_cap('read'); |
|
701 |
$role->add_cap('level_2'); |
|
702 |
$role->add_cap('level_1'); |
|
703 |
$role->add_cap('level_0'); |
|
704 |
||
705 |
// Add caps for Contributor role |
|
706 |
$role = get_role('contributor'); |
|
707 |
$role->add_cap('edit_posts'); |
|
708 |
$role->add_cap('read'); |
|
709 |
$role->add_cap('level_1'); |
|
710 |
$role->add_cap('level_0'); |
|
711 |
||
712 |
// Add caps for Subscriber role |
|
713 |
$role = get_role('subscriber'); |
|
714 |
$role->add_cap('read'); |
|
715 |
$role->add_cap('level_0'); |
|
716 |
} |
|
717 |
||
718 |
/** |
|
719 |
* Create and modify WordPress roles for WordPress 2.1. |
|
720 |
* |
|
721 |
* @since 2.1.0 |
|
722 |
*/ |
|
723 |
function populate_roles_210() { |
|
724 |
$roles = array('administrator', 'editor'); |
|
725 |
foreach ($roles as $role) { |
|
726 |
$role = get_role($role); |
|
727 |
if ( empty($role) ) |
|
728 |
continue; |
|
729 |
||
730 |
$role->add_cap('edit_others_pages'); |
|
731 |
$role->add_cap('edit_published_pages'); |
|
732 |
$role->add_cap('publish_pages'); |
|
733 |
$role->add_cap('delete_pages'); |
|
734 |
$role->add_cap('delete_others_pages'); |
|
735 |
$role->add_cap('delete_published_pages'); |
|
736 |
$role->add_cap('delete_posts'); |
|
737 |
$role->add_cap('delete_others_posts'); |
|
738 |
$role->add_cap('delete_published_posts'); |
|
739 |
$role->add_cap('delete_private_posts'); |
|
740 |
$role->add_cap('edit_private_posts'); |
|
741 |
$role->add_cap('read_private_posts'); |
|
742 |
$role->add_cap('delete_private_pages'); |
|
743 |
$role->add_cap('edit_private_pages'); |
|
744 |
$role->add_cap('read_private_pages'); |
|
745 |
} |
|
746 |
||
747 |
$role = get_role('administrator'); |
|
748 |
if ( ! empty($role) ) { |
|
749 |
$role->add_cap('delete_users'); |
|
750 |
$role->add_cap('create_users'); |
|
751 |
} |
|
752 |
||
753 |
$role = get_role('author'); |
|
754 |
if ( ! empty($role) ) { |
|
755 |
$role->add_cap('delete_posts'); |
|
756 |
$role->add_cap('delete_published_posts'); |
|
757 |
} |
|
758 |
||
759 |
$role = get_role('contributor'); |
|
760 |
if ( ! empty($role) ) { |
|
761 |
$role->add_cap('delete_posts'); |
|
762 |
} |
|
763 |
} |
|
764 |
||
765 |
/** |
|
766 |
* Create and modify WordPress roles for WordPress 2.3. |
|
767 |
* |
|
768 |
* @since 2.3.0 |
|
769 |
*/ |
|
770 |
function populate_roles_230() { |
|
771 |
$role = get_role( 'administrator' ); |
|
772 |
||
773 |
if ( !empty( $role ) ) { |
|
774 |
$role->add_cap( 'unfiltered_upload' ); |
|
775 |
} |
|
776 |
} |
|
777 |
||
778 |
/** |
|
779 |
* Create and modify WordPress roles for WordPress 2.5. |
|
780 |
* |
|
781 |
* @since 2.5.0 |
|
782 |
*/ |
|
783 |
function populate_roles_250() { |
|
784 |
$role = get_role( 'administrator' ); |
|
785 |
||
786 |
if ( !empty( $role ) ) { |
|
787 |
$role->add_cap( 'edit_dashboard' ); |
|
788 |
} |
|
789 |
} |
|
790 |
||
791 |
/** |
|
792 |
* Create and modify WordPress roles for WordPress 2.6. |
|
793 |
* |
|
794 |
* @since 2.6.0 |
|
795 |
*/ |
|
796 |
function populate_roles_260() { |
|
797 |
$role = get_role( 'administrator' ); |
|
798 |
||
799 |
if ( !empty( $role ) ) { |
|
800 |
$role->add_cap( 'update_plugins' ); |
|
801 |
$role->add_cap( 'delete_plugins' ); |
|
802 |
} |
|
803 |
} |
|
804 |
||
805 |
/** |
|
806 |
* Create and modify WordPress roles for WordPress 2.7. |
|
807 |
* |
|
808 |
* @since 2.7.0 |
|
809 |
*/ |
|
810 |
function populate_roles_270() { |
|
811 |
$role = get_role( 'administrator' ); |
|
812 |
||
813 |
if ( !empty( $role ) ) { |
|
814 |
$role->add_cap( 'install_plugins' ); |
|
815 |
$role->add_cap( 'update_themes' ); |
|
816 |
} |
|
817 |
} |
|
818 |
||
819 |
/** |
|
820 |
* Create and modify WordPress roles for WordPress 2.8. |
|
821 |
* |
|
822 |
* @since 2.8.0 |
|
823 |
*/ |
|
824 |
function populate_roles_280() { |
|
825 |
$role = get_role( 'administrator' ); |
|
826 |
||
827 |
if ( !empty( $role ) ) { |
|
828 |
$role->add_cap( 'install_themes' ); |
|
829 |
} |
|
830 |
} |
|
831 |
||
832 |
/** |
|
833 |
* Create and modify WordPress roles for WordPress 3.0. |
|
834 |
* |
|
835 |
* @since 3.0.0 |
|
836 |
*/ |
|
837 |
function populate_roles_300() { |
|
838 |
$role = get_role( 'administrator' ); |
|
839 |
||
840 |
if ( !empty( $role ) ) { |
|
841 |
$role->add_cap( 'update_core' ); |
|
842 |
$role->add_cap( 'list_users' ); |
|
843 |
$role->add_cap( 'remove_users' ); |
|
844 |
$role->add_cap( 'promote_users' ); |
|
845 |
$role->add_cap( 'edit_theme_options' ); |
|
846 |
$role->add_cap( 'delete_themes' ); |
|
847 |
$role->add_cap( 'export' ); |
|
848 |
} |
|
849 |
} |
|
850 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
if ( !function_exists( 'install_network' ) ) : |
0 | 852 |
/** |
853 |
* Install Network. |
|
854 |
* |
|
855 |
* @since 3.0.0 |
|
856 |
*/ |
|
857 |
function install_network() { |
|
858 |
if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) |
|
859 |
define( 'WP_INSTALLING_NETWORK', true ); |
|
860 |
||
861 |
dbDelta( wp_get_db_schema( 'global' ) ); |
|
862 |
} |
|
863 |
endif; |
|
864 |
||
865 |
/** |
|
5 | 866 |
* Populate network settings. |
0 | 867 |
* |
868 |
* @since 3.0.0 |
|
869 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
* @global wpdb $wpdb |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
* @global object $current_site |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
872 |
* @global int $wp_db_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
* @global WP_Rewrite $wp_rewrite |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
875 |
* @param int $network_id ID of network to populate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
* @param string $domain The domain name for the network (eg. "example.com"). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
* @param string $email Email address for the network administrator. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
878 |
* @param string $site_name The name of the network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
* @param string $path Optional. The path to append to the network's domain name. Default '/'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
* @param bool $subdomain_install Optional. Whether the network is a subdomain installation or a subdirectory installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
* Default false, meaning the network is a subdirectory installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
* @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful, |
5 | 883 |
* so the error code must be checked) or failure. |
0 | 884 |
*/ |
885 |
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { |
|
886 |
global $wpdb, $current_site, $wp_db_version, $wp_rewrite; |
|
887 |
||
888 |
$errors = new WP_Error(); |
|
889 |
if ( '' == $domain ) |
|
890 |
$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); |
|
891 |
if ( '' == $site_name ) |
|
892 |
$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); |
|
893 |
||
5 | 894 |
// Check for network collision. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
895 |
$network_exists = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
if ( is_multisite() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
if ( get_network( (int) $network_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
$errors->add( 'siteid_exists', __( 'The network already exists.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
899 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
$errors->add( 'siteid_exists', __( 'The network already exists.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
} |
0 | 905 |
|
906 |
if ( ! is_email( $email ) ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); |
0 | 908 |
|
909 |
if ( $errors->get_error_code() ) |
|
910 |
return $errors; |
|
911 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
// If a user with the provided email does not exist, default to the current user as the new network admin. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
$site_user = get_user_by( 'email', $email ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
if ( false === $site_user ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
$site_user = wp_get_current_user(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
|
5 | 918 |
// Set up site tables. |
0 | 919 |
$template = get_option( 'template' ); |
920 |
$stylesheet = get_option( 'stylesheet' ); |
|
921 |
$allowed_themes = array( $stylesheet => true ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
if ( $template != $stylesheet ) { |
0 | 924 |
$allowed_themes[ $template ] = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
926 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { |
0 | 928 |
$allowed_themes[ WP_DEFAULT_THEME ] = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
// If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
933 |
if ( $core_default = WP_Theme::get_core_default_theme() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
$allowed_themes[ $core_default->get_stylesheet() ] = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
} |
0 | 937 |
|
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 |
||
5 | 945 |
wp_cache_delete( 'networks_have_paths', 'site-options' ); |
946 |
||
0 | 947 |
if ( !is_multisite() ) { |
948 |
$site_admins = array( $site_user->user_login ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
949 |
$users = get_users( array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
'fields' => array( 'user_login' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
'role' => 'administrator', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
) ); |
0 | 953 |
if ( $users ) { |
954 |
foreach ( $users as $user ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
$site_admins[] = $user->user_login; |
0 | 956 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
958 |
$site_admins = array_unique( $site_admins ); |
0 | 959 |
} |
960 |
} else { |
|
961 |
$site_admins = get_site_option( 'site_admins' ); |
|
962 |
} |
|
963 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ |
5 | 965 |
$welcome_email = __( 'Howdy USERNAME, |
0 | 966 |
|
967 |
Your new SITE_NAME site has been successfully set up at: |
|
968 |
BLOG_URL |
|
969 |
||
970 |
You can log in to the administrator account with the following information: |
|
5 | 971 |
|
0 | 972 |
Username: USERNAME |
973 |
Password: PASSWORD |
|
974 |
Log in here: BLOG_URLwp-login.php |
|
975 |
||
976 |
We hope you enjoy your new site. Thanks! |
|
977 |
||
978 |
--The Team @ SITE_NAME' ); |
|
979 |
||
5 | 980 |
$misc_exts = array( |
981 |
// Images. |
|
982 |
'jpg', 'jpeg', 'png', 'gif', |
|
983 |
// Video. |
|
984 |
'mov', 'avi', 'mpg', '3gp', '3g2', |
|
985 |
// "audio". |
|
986 |
'midi', 'mid', |
|
987 |
// Miscellaneous. |
|
988 |
'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key', |
|
989 |
); |
|
990 |
$audio_exts = wp_get_audio_extensions(); |
|
991 |
$video_exts = wp_get_video_extensions(); |
|
992 |
$upload_filetypes = array_unique( array_merge( $misc_exts, $audio_exts, $video_exts ) ); |
|
993 |
||
0 | 994 |
$sitemeta = array( |
995 |
'site_name' => $site_name, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
'admin_email' => $email, |
0 | 997 |
'admin_user_id' => $site_user->ID, |
998 |
'registration' => 'none', |
|
5 | 999 |
'upload_filetypes' => implode( ' ', $upload_filetypes ), |
0 | 1000 |
'blog_upload_space' => 100, |
1001 |
'fileupload_maxk' => 1500, |
|
1002 |
'site_admins' => $site_admins, |
|
1003 |
'allowedthemes' => $allowed_themes, |
|
1004 |
'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ), |
|
1005 |
'wpmu_upgrade_site' => $wp_db_version, |
|
1006 |
'welcome_email' => $welcome_email, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
/* translators: %s: site link */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ), |
0 | 1009 |
// @todo - network admins should have a method of editing the network siteurl (used for cookie hash) |
1010 |
'siteurl' => get_option( 'siteurl' ) . '/', |
|
1011 |
'add_new_users' => '0', |
|
1012 |
'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', |
|
1013 |
'subdomain_install' => intval( $subdomain_install ), |
|
1014 |
'global_terms_enabled' => global_terms_enabled() ? '1' : '0', |
|
1015 |
'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', |
|
1016 |
'initial_db_version' => get_option( 'initial_db_version' ), |
|
1017 |
'active_sitewide_plugins' => array(), |
|
1018 |
'WPLANG' => get_locale(), |
|
1019 |
); |
|
1020 |
if ( ! $subdomain_install ) |
|
1021 |
$sitemeta['illegal_names'][] = 'blog'; |
|
1022 |
||
1023 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
* Filters meta for a network on creation. |
0 | 1025 |
* |
1026 |
* @since 3.7.0 |
|
1027 |
* |
|
5 | 1028 |
* @param array $sitemeta Associative array of network meta keys and values to be inserted. |
1029 |
* @param int $network_id ID of network to populate. |
|
0 | 1030 |
*/ |
1031 |
$sitemeta = apply_filters( 'populate_network_meta', $sitemeta, $network_id ); |
|
1032 |
||
1033 |
$insert = ''; |
|
1034 |
foreach ( $sitemeta as $meta_key => $meta_value ) { |
|
1035 |
if ( is_array( $meta_value ) ) |
|
1036 |
$meta_value = serialize( $meta_value ); |
|
1037 |
if ( !empty( $insert ) ) |
|
1038 |
$insert .= ', '; |
|
1039 |
$insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value ); |
|
1040 |
} |
|
1041 |
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert ); |
|
1042 |
||
5 | 1043 |
/* |
1044 |
* When upgrading from single to multisite, assume the current site will |
|
1045 |
* become the main site of the network. When using populate_network() |
|
1046 |
* to create another network in an existing multisite environment, skip |
|
1047 |
* these steps since the main site of the new network has not yet been |
|
1048 |
* created. |
|
1049 |
*/ |
|
0 | 1050 |
if ( ! is_multisite() ) { |
1051 |
$current_site = new stdClass; |
|
1052 |
$current_site->domain = $domain; |
|
1053 |
$current_site->path = $path; |
|
1054 |
$current_site->site_name = ucfirst( $domain ); |
|
1055 |
$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) ); |
|
1056 |
$current_site->blog_id = $blog_id = $wpdb->insert_id; |
|
1057 |
update_user_meta( $site_user->ID, 'source_domain', $domain ); |
|
1058 |
update_user_meta( $site_user->ID, 'primary_blog', $blog_id ); |
|
1059 |
||
1060 |
if ( $subdomain_install ) |
|
1061 |
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); |
|
1062 |
else |
|
1063 |
$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' ); |
|
1064 |
||
1065 |
flush_rewrite_rules(); |
|
1066 |
||
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>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
$msg .= '<p>' . sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
/* translators: %s: host name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
__( 'The installer attempted to contact a random hostname (%s) on your domain.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
'<code>' . $hostname . '</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
if ( ! empty ( $errstr ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
/* translators: %s: error message */ |
0 | 1089 |
$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
} |
0 | 1091 |
$msg .= '</p>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1092 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
$msg .= '<p>' . sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
/* translators: %s: asterisk symbol (*) */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
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.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
'<code>*</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
) . '</p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
|
0 | 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>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
|
0 | 1101 |
return new WP_Error( 'no_wildcard_dns', $msg ); |
1102 |
} |
|
1103 |
} |
|
1104 |
||
1105 |
return true; |
|
1106 |
} |