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