Projects : mp-wp : mp-wp_svg-screenshots-and-errorreporting-r2
1 | <?php |
2 | /** |
3 | * WordPress Administration Scheme API |
4 | * |
5 | * Here we keep the DB structure and option values. |
6 | * |
7 | * @package WordPress |
8 | * @subpackage Administration |
9 | */ |
10 | |
11 | /** |
12 | * The database character collate. |
13 | * @var string |
14 | * @global string |
15 | * @name $charset_collate |
16 | */ |
17 | $charset_collate = ''; |
18 | |
19 | // Declare these as global in case schema.php is included from a function. |
20 | global $wpdb, $wp_queries; |
21 | |
22 | if ( $wpdb->has_cap( 'collation' ) ) { |
23 | if ( ! empty($wpdb->charset) ) |
24 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; |
25 | if ( ! empty($wpdb->collate) ) |
26 | $charset_collate .= " COLLATE $wpdb->collate"; |
27 | } |
28 | |
29 | /** Create WordPress database tables SQL */ |
30 | $wp_queries = "CREATE TABLE $wpdb->terms ( |
31 | term_id bigint(20) NOT NULL auto_increment, |
32 | name varchar(200) NOT NULL default '', |
33 | slug varchar(200) NOT NULL default '', |
34 | term_group bigint(10) NOT NULL default 0, |
35 | PRIMARY KEY (term_id), |
36 | UNIQUE KEY slug (slug), |
37 | KEY name (name) |
38 | ) $charset_collate; |
39 | CREATE TABLE $wpdb->term_taxonomy ( |
40 | term_taxonomy_id bigint(20) NOT NULL auto_increment, |
41 | term_id bigint(20) NOT NULL default 0, |
42 | taxonomy varchar(32) NOT NULL default '', |
43 | description longtext NOT NULL, |
44 | parent bigint(20) NOT NULL default 0, |
45 | count bigint(20) NOT NULL default 0, |
46 | PRIMARY KEY (term_taxonomy_id), |
47 | UNIQUE KEY term_id_taxonomy (term_id,taxonomy) |
48 | ) $charset_collate; |
49 | CREATE TABLE $wpdb->term_relationships ( |
50 | object_id bigint(20) NOT NULL default 0, |
51 | term_taxonomy_id bigint(20) NOT NULL default 0, |
52 | term_order int(11) NOT NULL default 0, |
53 | PRIMARY KEY (object_id,term_taxonomy_id), |
54 | KEY term_taxonomy_id (term_taxonomy_id) |
55 | ) $charset_collate; |
56 | CREATE TABLE $wpdb->comments ( |
57 | comment_ID bigint(20) unsigned NOT NULL auto_increment, |
58 | comment_post_ID int(11) NOT NULL default '0', |
59 | comment_author tinytext NOT NULL, |
60 | comment_author_email varchar(100) NOT NULL default '', |
61 | comment_author_url varchar(200) NOT NULL default '', |
62 | comment_author_IP varchar(100) NOT NULL default '', |
63 | comment_date datetime NOT NULL default '0000-00-00 00:00:00', |
64 | comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', |
65 | comment_content text NOT NULL, |
66 | comment_karma int(11) NOT NULL default '0', |
67 | comment_approved varchar(20) NOT NULL default '1', |
68 | comment_agent varchar(255) NOT NULL default '', |
69 | comment_type varchar(20) NOT NULL default '', |
70 | comment_parent bigint(20) NOT NULL default '0', |
71 | user_id bigint(20) NOT NULL default '0', |
72 | PRIMARY KEY (comment_ID), |
73 | KEY comment_approved (comment_approved), |
74 | KEY comment_post_ID (comment_post_ID), |
75 | KEY comment_approved_date_gmt (comment_approved,comment_date_gmt), |
76 | KEY comment_date_gmt (comment_date_gmt) |
77 | ) $charset_collate; |
78 | CREATE TABLE $wpdb->links ( |
79 | link_id bigint(20) NOT NULL auto_increment, |
80 | link_url varchar(255) NOT NULL default '', |
81 | link_name varchar(255) NOT NULL default '', |
82 | link_image varchar(255) NOT NULL default '', |
83 | link_target varchar(25) NOT NULL default '', |
84 | link_category bigint(20) NOT NULL default '0', |
85 | link_description varchar(255) NOT NULL default '', |
86 | link_visible varchar(20) NOT NULL default 'Y', |
87 | link_owner int(11) NOT NULL default '1', |
88 | link_rating int(11) NOT NULL default '0', |
89 | link_updated datetime NOT NULL default '0000-00-00 00:00:00', |
90 | link_rel varchar(255) NOT NULL default '', |
91 | link_notes mediumtext NOT NULL, |
92 | link_rss varchar(255) NOT NULL default '', |
93 | PRIMARY KEY (link_id), |
94 | KEY link_category (link_category), |
95 | KEY link_visible (link_visible) |
96 | ) $charset_collate; |
97 | CREATE TABLE $wpdb->options ( |
98 | option_id bigint(20) NOT NULL auto_increment, |
99 | blog_id int(11) NOT NULL default '0', |
100 | option_name varchar(64) NOT NULL default '', |
101 | option_value longtext NOT NULL, |
102 | autoload varchar(20) NOT NULL default 'yes', |
103 | PRIMARY KEY (option_id,blog_id,option_name), |
104 | KEY option_name (option_name) |
105 | ) $charset_collate; |
106 | CREATE TABLE $wpdb->postmeta ( |
107 | meta_id bigint(20) NOT NULL auto_increment, |
108 | post_id bigint(20) NOT NULL default '0', |
109 | meta_key varchar(255) default NULL, |
110 | meta_value longtext, |
111 | PRIMARY KEY (meta_id), |
112 | KEY post_id (post_id), |
113 | KEY meta_key (meta_key) |
114 | ) $charset_collate; |
115 | CREATE TABLE $wpdb->posts ( |
116 | ID bigint(20) unsigned NOT NULL auto_increment, |
117 | post_author bigint(20) NOT NULL default '0', |
118 | post_date datetime NOT NULL default '0000-00-00 00:00:00', |
119 | post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00', |
120 | post_content longtext NOT NULL, |
121 | post_title text NOT NULL, |
122 | post_category int(4) NOT NULL default '0', |
123 | post_excerpt text NOT NULL, |
124 | post_status varchar(20) NOT NULL default 'publish', |
125 | comment_status varchar(20) NOT NULL default 'open', |
126 | ping_status varchar(20) NOT NULL default 'open', |
127 | post_password varchar(20) NOT NULL default '', |
128 | post_name varchar(200) NOT NULL default '', |
129 | to_ping text NOT NULL, |
130 | pinged text NOT NULL, |
131 | post_modified datetime NOT NULL default '0000-00-00 00:00:00', |
132 | post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00', |
133 | post_content_filtered text NOT NULL, |
134 | post_parent bigint(20) NOT NULL default '0', |
135 | guid varchar(255) NOT NULL default '', |
136 | menu_order int(11) NOT NULL default '0', |
137 | post_type varchar(20) NOT NULL default 'post', |
138 | post_mime_type varchar(100) NOT NULL default '', |
139 | comment_count bigint(20) NOT NULL default '0', |
140 | PRIMARY KEY (ID), |
141 | KEY post_name (post_name), |
142 | KEY type_status_date (post_type,post_status,post_date,ID), |
143 | KEY post_parent (post_parent) |
144 | ) $charset_collate; |
145 | CREATE TABLE $wpdb->users ( |
146 | ID bigint(20) unsigned NOT NULL auto_increment, |
147 | user_login varchar(60) NOT NULL default '', |
148 | user_pass varchar(64) NOT NULL default '', |
149 | user_nicename varchar(50) NOT NULL default '', |
150 | user_email varchar(100) NOT NULL default '', |
151 | user_url varchar(100) NOT NULL default '', |
152 | user_registered datetime NOT NULL default '0000-00-00 00:00:00', |
153 | user_activation_key varchar(60) NOT NULL default '', |
154 | user_status int(11) NOT NULL default '0', |
155 | display_name varchar(250) NOT NULL default '', |
156 | PRIMARY KEY (ID), |
157 | KEY user_login_key (user_login), |
158 | KEY user_nicename (user_nicename) |
159 | ) $charset_collate; |
160 | CREATE TABLE $wpdb->usermeta ( |
161 | umeta_id bigint(20) NOT NULL auto_increment, |
162 | user_id bigint(20) NOT NULL default '0', |
163 | meta_key varchar(255) default NULL, |
164 | meta_value longtext, |
165 | PRIMARY KEY (umeta_id), |
166 | KEY user_id (user_id), |
167 | KEY meta_key (meta_key) |
168 | ) $charset_collate;"; |
169 | |
170 | /** |
171 | * Create WordPress options and set the default values. |
172 | * |
173 | * @since 1.5.0 |
174 | * @uses $wpdb |
175 | * @uses $wp_db_version |
176 | */ |
177 | function populate_options() { |
178 | global $wpdb, $wp_db_version; |
179 | |
180 | $guessurl = wp_guess_url(); |
181 | |
182 | do_action('populate_options'); |
183 | |
184 | add_option('siteurl', $guessurl); |
185 | add_option('blogname', __('My Blog')); |
186 | add_option('blogdescription', __('Just another WordPress weblog')); |
187 | add_option('users_can_register', 0); |
188 | add_option('admin_email', 'you@example.com'); |
189 | add_option('start_of_week', 1); |
190 | add_option('use_balanceTags', 0); |
191 | add_option('use_smilies', 1); |
192 | add_option('require_name_email', 1); |
193 | add_option('comments_notify', 1); |
194 | add_option('posts_per_rss', 10); |
195 | add_option('rss_excerpt_length', 50); |
196 | add_option('rss_use_excerpt', 0); |
197 | add_option('default_category', 1); |
198 | add_option('default_comment_status', 'open'); |
199 | add_option('default_ping_status', 'open'); |
200 | add_option('default_pingback_flag', 1); |
201 | add_option('default_post_edit_rows', 10); |
202 | add_option('posts_per_page', 10); |
203 | add_option('what_to_show', 'posts'); |
204 | add_option('date_format', __('F j, Y')); |
205 | add_option('time_format', __('g:i a')); |
206 | add_option('links_updated_date_format', __('F j, Y g:i a')); |
207 | add_option('links_recently_updated_prepend', '<em>'); |
208 | add_option('links_recently_updated_append', '</em>'); |
209 | add_option('links_recently_updated_time', 120); |
210 | add_option('comment_moderation', 0); |
211 | add_option('moderation_notify', 1); |
212 | add_option('permalink_structure'); |
213 | add_option('gzipcompression', 0); |
214 | add_option('hack_file', 0); |
215 | add_option('blog_charset', 'UTF-8'); |
216 | add_option('moderation_keys'); |
217 | add_option('active_plugins'); |
218 | add_option('home', $guessurl); |
219 | // in case it is set, but blank, update "home" |
220 | if ( !__get_option('home') ) update_option('home', $guessurl); |
221 | add_option('category_base'); |
222 | add_option('ping_sites', 'http://rpc.pingomatic.com/'); |
223 | add_option('advanced_edit', 0); |
224 | add_option('comment_max_links', 2); |
225 | add_option('gmt_offset', date('Z') / 3600); |
226 | // 1.5 |
227 | add_option('default_email_category', 1); |
228 | add_option('recently_edited'); |
229 | add_option('use_linksupdate', 0); |
230 | add_option('template', 'default'); |
231 | add_option('stylesheet', 'default'); |
232 | add_option('comment_whitelist', 1); |
233 | add_option('page_uris'); |
234 | add_option('blacklist_keys'); |
235 | add_option('comment_registration', 0); |
236 | add_option('rss_language', 'en'); |
237 | add_option('html_type', 'text/html'); |
238 | // 1.5.1 |
239 | add_option('use_trackback', 0); |
240 | // 2.0 |
241 | add_option('default_role', 'subscriber'); |
242 | add_option('db_version', $wp_db_version); |
243 | // 2.0.1 |
244 | if ( ini_get('safe_mode') ) { |
245 | // Safe mode screws up mkdir(), so we must use a flat structure. |
246 | add_option('uploads_use_yearmonth_folders', 0); |
247 | add_option('upload_path', WP_CONTENT_DIR); |
248 | } else { |
249 | add_option('uploads_use_yearmonth_folders', 1); |
250 | add_option('upload_path', WP_CONTENT_DIR . '/uploads'); |
251 | } |
252 | |
253 | // 2.0.3 |
254 | add_option('secret', wp_generate_password(64)); |
255 | |
256 | // 2.1 |
257 | add_option('blog_public', '1'); |
258 | add_option('default_link_category', 2); |
259 | add_option('show_on_front', 'posts'); |
260 | |
261 | // 2.2 |
262 | add_option('tag_base'); |
263 | |
264 | // 2.5 |
265 | add_option('show_avatars', '1'); |
266 | add_option('avatar_rating', 'G'); |
267 | add_option('upload_url_path', ''); |
268 | add_option('thumbnail_size_w', 150); |
269 | add_option('thumbnail_size_h', 150); |
270 | add_option('thumbnail_crop', 1); |
271 | add_option('medium_size_w', 300); |
272 | add_option('medium_size_h', 300); |
273 | |
274 | // 2.6 |
275 | add_option('avatar_default', 'mystery'); |
276 | add_option('enable_app', 0); |
277 | add_option('enable_xmlrpc', 0); |
278 | |
279 | // 2.7 |
280 | add_option('large_size_w', 1024); |
281 | add_option('large_size_h', 1024); |
282 | add_option('image_default_link_type', 'file'); |
283 | add_option('image_default_size', ''); |
284 | add_option('image_default_align', ''); |
285 | add_option('close_comments_for_old_posts', 0); |
286 | add_option('close_comments_days_old', 14); |
287 | add_option('thread_comments', 0); |
288 | add_option('thread_comments_depth', 5); |
289 | add_option('page_comments', 1); |
290 | add_option('comments_per_page', 50); |
291 | add_option('default_comments_page', 'newest'); |
292 | add_option('comment_order', 'asc'); |
293 | add_option('use_ssl', 0); |
294 | add_option('sticky_posts', array()); |
295 | add_option('widget_categories', array()); |
296 | add_option('widget_text', array()); |
297 | add_option('widget_rss', array()); |
298 | add_option('update_core', array()); |
299 | add_option('dismissed_update_core', array()); |
300 | |
301 | // Delete unused options |
302 | $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'); |
303 | foreach ($unusedoptions as $option) : |
304 | delete_option($option); |
305 | endforeach; |
306 | |
307 | // Set up a few options not to load by default |
308 | $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' ); |
309 | foreach ($fatoptions as $fatoption) : |
310 | $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'"); |
311 | endforeach; |
312 | } |
313 | |
314 | /** |
315 | * Execute WordPress role creation for the various WordPress versions. |
316 | * |
317 | * @since 2.0.0 |
318 | */ |
319 | function populate_roles() { |
320 | populate_roles_160(); |
321 | populate_roles_210(); |
322 | populate_roles_230(); |
323 | populate_roles_250(); |
324 | populate_roles_260(); |
325 | populate_roles_270(); |
326 | } |
327 | |
328 | /** |
329 | * Create the roles for WordPress 2.0 |
330 | * |
331 | * @since 2.0.0 |
332 | */ |
333 | function populate_roles_160() { |
334 | // Add roles |
335 | |
336 | // Dummy gettext calls to get strings in the catalog. |
337 | _c('Administrator|User role'); |
338 | _c('Editor|User role'); |
339 | _c('Author|User role'); |
340 | _c('Contributor|User role'); |
341 | _c('Subscriber|User role'); |
342 | |
343 | add_role('administrator', 'Administrator|User role'); |
344 | add_role('editor', 'Editor|User role'); |
345 | add_role('author', 'Author|User role'); |
346 | add_role('contributor', 'Contributor|User role'); |
347 | add_role('subscriber', 'Subscriber|User role'); |
348 | |
349 | // Add caps for Administrator role |
350 | $role = get_role('administrator'); |
351 | $role->add_cap('switch_themes'); |
352 | $role->add_cap('edit_themes'); |
353 | $role->add_cap('activate_plugins'); |
354 | $role->add_cap('edit_plugins'); |
355 | $role->add_cap('edit_users'); |
356 | $role->add_cap('edit_files'); |
357 | $role->add_cap('manage_options'); |
358 | $role->add_cap('moderate_comments'); |
359 | $role->add_cap('manage_categories'); |
360 | $role->add_cap('manage_links'); |
361 | $role->add_cap('upload_files'); |
362 | $role->add_cap('import'); |
363 | $role->add_cap('unfiltered_html'); |
364 | $role->add_cap('edit_posts'); |
365 | $role->add_cap('edit_others_posts'); |
366 | $role->add_cap('edit_published_posts'); |
367 | $role->add_cap('publish_posts'); |
368 | $role->add_cap('edit_pages'); |
369 | $role->add_cap('read'); |
370 | $role->add_cap('level_10'); |
371 | $role->add_cap('level_9'); |
372 | $role->add_cap('level_8'); |
373 | $role->add_cap('level_7'); |
374 | $role->add_cap('level_6'); |
375 | $role->add_cap('level_5'); |
376 | $role->add_cap('level_4'); |
377 | $role->add_cap('level_3'); |
378 | $role->add_cap('level_2'); |
379 | $role->add_cap('level_1'); |
380 | $role->add_cap('level_0'); |
381 | |
382 | // Add caps for Editor role |
383 | $role = get_role('editor'); |
384 | $role->add_cap('moderate_comments'); |
385 | $role->add_cap('manage_categories'); |
386 | $role->add_cap('manage_links'); |
387 | $role->add_cap('upload_files'); |
388 | $role->add_cap('unfiltered_html'); |
389 | $role->add_cap('edit_posts'); |
390 | $role->add_cap('edit_others_posts'); |
391 | $role->add_cap('edit_published_posts'); |
392 | $role->add_cap('publish_posts'); |
393 | $role->add_cap('edit_pages'); |
394 | $role->add_cap('read'); |
395 | $role->add_cap('level_7'); |
396 | $role->add_cap('level_6'); |
397 | $role->add_cap('level_5'); |
398 | $role->add_cap('level_4'); |
399 | $role->add_cap('level_3'); |
400 | $role->add_cap('level_2'); |
401 | $role->add_cap('level_1'); |
402 | $role->add_cap('level_0'); |
403 | |
404 | // Add caps for Author role |
405 | $role = get_role('author'); |
406 | $role->add_cap('upload_files'); |
407 | $role->add_cap('edit_posts'); |
408 | $role->add_cap('edit_published_posts'); |
409 | $role->add_cap('publish_posts'); |
410 | $role->add_cap('read'); |
411 | $role->add_cap('level_2'); |
412 | $role->add_cap('level_1'); |
413 | $role->add_cap('level_0'); |
414 | |
415 | // Add caps for Contributor role |
416 | $role = get_role('contributor'); |
417 | $role->add_cap('edit_posts'); |
418 | $role->add_cap('read'); |
419 | $role->add_cap('level_1'); |
420 | $role->add_cap('level_0'); |
421 | |
422 | // Add caps for Subscriber role |
423 | $role = get_role('subscriber'); |
424 | $role->add_cap('read'); |
425 | $role->add_cap('level_0'); |
426 | } |
427 | |
428 | /** |
429 | * Create and modify WordPress roles for WordPress 2.1. |
430 | * |
431 | * @since 2.1.0 |
432 | */ |
433 | function populate_roles_210() { |
434 | $roles = array('administrator', 'editor'); |
435 | foreach ($roles as $role) { |
436 | $role = get_role($role); |
437 | if ( empty($role) ) |
438 | continue; |
439 | |
440 | $role->add_cap('edit_others_pages'); |
441 | $role->add_cap('edit_published_pages'); |
442 | $role->add_cap('publish_pages'); |
443 | $role->add_cap('delete_pages'); |
444 | $role->add_cap('delete_others_pages'); |
445 | $role->add_cap('delete_published_pages'); |
446 | $role->add_cap('delete_posts'); |
447 | $role->add_cap('delete_others_posts'); |
448 | $role->add_cap('delete_published_posts'); |
449 | $role->add_cap('delete_private_posts'); |
450 | $role->add_cap('edit_private_posts'); |
451 | $role->add_cap('read_private_posts'); |
452 | $role->add_cap('delete_private_pages'); |
453 | $role->add_cap('edit_private_pages'); |
454 | $role->add_cap('read_private_pages'); |
455 | } |
456 | |
457 | $role = get_role('administrator'); |
458 | if ( ! empty($role) ) { |
459 | $role->add_cap('delete_users'); |
460 | $role->add_cap('create_users'); |
461 | } |
462 | |
463 | $role = get_role('author'); |
464 | if ( ! empty($role) ) { |
465 | $role->add_cap('delete_posts'); |
466 | $role->add_cap('delete_published_posts'); |
467 | } |
468 | |
469 | $role = get_role('contributor'); |
470 | if ( ! empty($role) ) { |
471 | $role->add_cap('delete_posts'); |
472 | } |
473 | } |
474 | |
475 | /** |
476 | * Create and modify WordPress roles for WordPress 2.3. |
477 | * |
478 | * @since 2.3.0 |
479 | */ |
480 | function populate_roles_230() { |
481 | $role = get_role( 'administrator' ); |
482 | |
483 | if ( !empty( $role ) ) { |
484 | $role->add_cap( 'unfiltered_upload' ); |
485 | } |
486 | } |
487 | |
488 | /** |
489 | * Create and modify WordPress roles for WordPress 2.5. |
490 | * |
491 | * @since 2.5.0 |
492 | */ |
493 | function populate_roles_250() { |
494 | $role = get_role( 'administrator' ); |
495 | |
496 | if ( !empty( $role ) ) { |
497 | $role->add_cap( 'edit_dashboard' ); |
498 | } |
499 | } |
500 | |
501 | /** |
502 | * Create and modify WordPress roles for WordPress 2.6. |
503 | * |
504 | * @since 2.6.0 |
505 | */ |
506 | function populate_roles_260() { |
507 | $role = get_role( 'administrator' ); |
508 | |
509 | if ( !empty( $role ) ) { |
510 | $role->add_cap( 'update_plugins' ); |
511 | $role->add_cap( 'delete_plugins' ); |
512 | } |
513 | } |
514 | |
515 | /** |
516 | * Create and modify WordPress roles for WordPress 2.7. |
517 | * |
518 | * @since 2.7.0 |
519 | */ |
520 | function populate_roles_270() { |
521 | $role = get_role( 'administrator' ); |
522 | |
523 | if ( !empty( $role ) ) { |
524 | $role->add_cap( 'install_plugins' ); |
525 | $role->add_cap( 'update_themes' ); |
526 | } |
527 | } |
528 | |
529 | ?> |