-
+ 261CB6FC5FC05C18A47689861FEAE94267B0BA35FA4E2F7138A2671AB615F553D10D345D6869187F3080E99DAFFA1BD0924A2C65F6D7955728C0D815AB176C95
mp-wp/wp-admin/includes/schema.php
(0 . 0)(1 . 533)
40157 <?php
40158 /**
40159 * WordPress Administration Scheme API
40160 *
40161 * Here we keep the DB structure and option values.
40162 *
40163 * @package WordPress
40164 * @subpackage Administration
40165 */
40166
40167 /**
40168 * The database character collate.
40169 * @var string
40170 * @global string
40171 * @name $charset_collate
40172 */
40173 $charset_collate = '';
40174
40175 // Declare these as global in case schema.php is included from a function.
40176 global $wpdb, $wp_queries;
40177
40178 if ( $wpdb->has_cap( 'collation' ) ) {
40179 if ( ! empty($wpdb->charset) )
40180 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
40181 if ( ! empty($wpdb->collate) )
40182 $charset_collate .= " COLLATE $wpdb->collate";
40183 }
40184
40185 /** Create WordPress database tables SQL */
40186 $wp_queries = "CREATE TABLE $wpdb->terms (
40187 term_id bigint(20) NOT NULL auto_increment,
40188 name varchar(200) NOT NULL default '',
40189 slug varchar(200) NOT NULL default '',
40190 term_group bigint(10) NOT NULL default 0,
40191 PRIMARY KEY (term_id),
40192 UNIQUE KEY slug (slug),
40193 KEY name (name)
40194 ) $charset_collate;
40195 CREATE TABLE $wpdb->term_taxonomy (
40196 term_taxonomy_id bigint(20) NOT NULL auto_increment,
40197 term_id bigint(20) NOT NULL default 0,
40198 taxonomy varchar(32) NOT NULL default '',
40199 description longtext NOT NULL,
40200 parent bigint(20) NOT NULL default 0,
40201 count bigint(20) NOT NULL default 0,
40202 PRIMARY KEY (term_taxonomy_id),
40203 UNIQUE KEY term_id_taxonomy (term_id,taxonomy)
40204 ) $charset_collate;
40205 CREATE TABLE $wpdb->term_relationships (
40206 object_id bigint(20) NOT NULL default 0,
40207 term_taxonomy_id bigint(20) NOT NULL default 0,
40208 term_order int(11) NOT NULL default 0,
40209 PRIMARY KEY (object_id,term_taxonomy_id),
40210 KEY term_taxonomy_id (term_taxonomy_id)
40211 ) $charset_collate;
40212 CREATE TABLE $wpdb->comments (
40213 comment_ID bigint(20) unsigned NOT NULL auto_increment,
40214 comment_post_ID int(11) NOT NULL default '0',
40215 comment_author tinytext NOT NULL,
40216 comment_author_email varchar(100) NOT NULL default '',
40217 comment_author_url varchar(200) NOT NULL default '',
40218 comment_author_IP varchar(100) NOT NULL default '',
40219 comment_date datetime NOT NULL default '0000-00-00 00:00:00',
40220 comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
40221 comment_content text NOT NULL,
40222 comment_karma int(11) NOT NULL default '0',
40223 comment_approved varchar(20) NOT NULL default '1',
40224 comment_agent varchar(255) NOT NULL default '',
40225 comment_type varchar(20) NOT NULL default '',
40226 comment_parent bigint(20) NOT NULL default '0',
40227 user_id bigint(20) NOT NULL default '0',
40228 PRIMARY KEY (comment_ID),
40229 KEY comment_approved (comment_approved),
40230 KEY comment_post_ID (comment_post_ID),
40231 KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
40232 KEY comment_date_gmt (comment_date_gmt)
40233 ) $charset_collate;
40234 CREATE TABLE $wpdb->links (
40235 link_id bigint(20) NOT NULL auto_increment,
40236 link_url varchar(255) NOT NULL default '',
40237 link_name varchar(255) NOT NULL default '',
40238 link_image varchar(255) NOT NULL default '',
40239 link_target varchar(25) NOT NULL default '',
40240 link_category bigint(20) NOT NULL default '0',
40241 link_description varchar(255) NOT NULL default '',
40242 link_visible varchar(20) NOT NULL default 'Y',
40243 link_owner int(11) NOT NULL default '1',
40244 link_rating int(11) NOT NULL default '0',
40245 link_updated datetime NOT NULL default '0000-00-00 00:00:00',
40246 link_rel varchar(255) NOT NULL default '',
40247 link_notes mediumtext NOT NULL,
40248 link_rss varchar(255) NOT NULL default '',
40249 PRIMARY KEY (link_id),
40250 KEY link_category (link_category),
40251 KEY link_visible (link_visible)
40252 ) $charset_collate;
40253 CREATE TABLE $wpdb->options (
40254 option_id bigint(20) NOT NULL auto_increment,
40255 blog_id int(11) NOT NULL default '0',
40256 option_name varchar(64) NOT NULL default '',
40257 option_value longtext NOT NULL,
40258 autoload varchar(20) NOT NULL default 'yes',
40259 PRIMARY KEY (option_id,blog_id,option_name),
40260 KEY option_name (option_name)
40261 ) $charset_collate;
40262 CREATE TABLE $wpdb->postmeta (
40263 meta_id bigint(20) NOT NULL auto_increment,
40264 post_id bigint(20) NOT NULL default '0',
40265 meta_key varchar(255) default NULL,
40266 meta_value longtext,
40267 PRIMARY KEY (meta_id),
40268 KEY post_id (post_id),
40269 KEY meta_key (meta_key)
40270 ) $charset_collate;
40271 CREATE TABLE $wpdb->posts (
40272 ID bigint(20) unsigned NOT NULL auto_increment,
40273 post_author bigint(20) NOT NULL default '0',
40274 post_date datetime NOT NULL default '0000-00-00 00:00:00',
40275 post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
40276 post_content longtext NOT NULL,
40277 post_title text NOT NULL,
40278 post_category int(4) NOT NULL default '0',
40279 post_excerpt text NOT NULL,
40280 post_status varchar(20) NOT NULL default 'publish',
40281 comment_status varchar(20) NOT NULL default 'open',
40282 ping_status varchar(20) NOT NULL default 'open',
40283 post_password varchar(20) NOT NULL default '',
40284 post_name varchar(200) NOT NULL default '',
40285 to_ping text NOT NULL,
40286 pinged text NOT NULL,
40287 post_modified datetime NOT NULL default '0000-00-00 00:00:00',
40288 post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
40289 post_content_filtered text NOT NULL,
40290 post_parent bigint(20) NOT NULL default '0',
40291 guid varchar(255) NOT NULL default '',
40292 menu_order int(11) NOT NULL default '0',
40293 post_type varchar(20) NOT NULL default 'post',
40294 post_mime_type varchar(100) NOT NULL default '',
40295 comment_count bigint(20) NOT NULL default '0',
40296 PRIMARY KEY (ID),
40297 KEY post_name (post_name),
40298 KEY type_status_date (post_type,post_status,post_date,ID),
40299 KEY post_parent (post_parent)
40300 ) $charset_collate;
40301 CREATE TABLE $wpdb->users (
40302 ID bigint(20) unsigned NOT NULL auto_increment,
40303 user_login varchar(60) NOT NULL default '',
40304 user_pass varchar(64) NOT NULL default '',
40305 user_nicename varchar(50) NOT NULL default '',
40306 user_email varchar(100) NOT NULL default '',
40307 user_url varchar(100) NOT NULL default '',
40308 user_registered datetime NOT NULL default '0000-00-00 00:00:00',
40309 user_activation_key varchar(60) NOT NULL default '',
40310 user_status int(11) NOT NULL default '0',
40311 display_name varchar(250) NOT NULL default '',
40312 PRIMARY KEY (ID),
40313 KEY user_login_key (user_login),
40314 KEY user_nicename (user_nicename)
40315 ) $charset_collate;
40316 CREATE TABLE $wpdb->usermeta (
40317 umeta_id bigint(20) NOT NULL auto_increment,
40318 user_id bigint(20) NOT NULL default '0',
40319 meta_key varchar(255) default NULL,
40320 meta_value longtext,
40321 PRIMARY KEY (umeta_id),
40322 KEY user_id (user_id),
40323 KEY meta_key (meta_key)
40324 ) $charset_collate;";
40325
40326 /**
40327 * Create WordPress options and set the default values.
40328 *
40329 * @since 1.5.0
40330 * @uses $wpdb
40331 * @uses $wp_db_version
40332 */
40333 function populate_options() {
40334 global $wpdb, $wp_db_version;
40335
40336 $guessurl = wp_guess_url();
40337
40338 do_action('populate_options');
40339
40340 add_option('siteurl', $guessurl);
40341 add_option('blogname', __('My Blog'));
40342 add_option('blogdescription', __('Just another WordPress weblog'));
40343 add_option('users_can_register', 0);
40344 add_option('admin_email', 'you@example.com');
40345 add_option('start_of_week', 1);
40346 add_option('use_balanceTags', 0);
40347 add_option('use_smilies', 1);
40348 add_option('require_name_email', 1);
40349 add_option('comments_notify', 1);
40350 add_option('posts_per_rss', 10);
40351 add_option('rss_excerpt_length', 50);
40352 add_option('rss_use_excerpt', 0);
40353 add_option('mailserver_url', 'mail.example.com');
40354 add_option('mailserver_login', 'login@example.com');
40355 add_option('mailserver_pass', 'password');
40356 add_option('mailserver_port', 110);
40357 add_option('default_category', 1);
40358 add_option('default_comment_status', 'open');
40359 add_option('default_ping_status', 'open');
40360 add_option('default_pingback_flag', 1);
40361 add_option('default_post_edit_rows', 10);
40362 add_option('posts_per_page', 10);
40363 add_option('what_to_show', 'posts');
40364 add_option('date_format', __('F j, Y'));
40365 add_option('time_format', __('g:i a'));
40366 add_option('links_updated_date_format', __('F j, Y g:i a'));
40367 add_option('links_recently_updated_prepend', '<em>');
40368 add_option('links_recently_updated_append', '</em>');
40369 add_option('links_recently_updated_time', 120);
40370 add_option('comment_moderation', 0);
40371 add_option('moderation_notify', 1);
40372 add_option('permalink_structure');
40373 add_option('gzipcompression', 0);
40374 add_option('hack_file', 0);
40375 add_option('blog_charset', 'UTF-8');
40376 add_option('moderation_keys');
40377 add_option('active_plugins');
40378 add_option('home', $guessurl);
40379 // in case it is set, but blank, update "home"
40380 if ( !__get_option('home') ) update_option('home', $guessurl);
40381 add_option('category_base');
40382 add_option('ping_sites', 'http://rpc.pingomatic.com/');
40383 add_option('advanced_edit', 0);
40384 add_option('comment_max_links', 2);
40385 add_option('gmt_offset', date('Z') / 3600);
40386 // 1.5
40387 add_option('default_email_category', 1);
40388 add_option('recently_edited');
40389 add_option('use_linksupdate', 0);
40390 add_option('template', 'default');
40391 add_option('stylesheet', 'default');
40392 add_option('comment_whitelist', 1);
40393 add_option('page_uris');
40394 add_option('blacklist_keys');
40395 add_option('comment_registration', 0);
40396 add_option('rss_language', 'en');
40397 add_option('html_type', 'text/html');
40398 // 1.5.1
40399 add_option('use_trackback', 0);
40400 // 2.0
40401 add_option('default_role', 'subscriber');
40402 add_option('db_version', $wp_db_version);
40403 // 2.0.1
40404 if ( ini_get('safe_mode') ) {
40405 // Safe mode screws up mkdir(), so we must use a flat structure.
40406 add_option('uploads_use_yearmonth_folders', 0);
40407 add_option('upload_path', WP_CONTENT_DIR);
40408 } else {
40409 add_option('uploads_use_yearmonth_folders', 1);
40410 add_option('upload_path', WP_CONTENT_DIR . '/uploads');
40411 }
40412
40413 // 2.0.3
40414 add_option('secret', wp_generate_password(64));
40415
40416 // 2.1
40417 add_option('blog_public', '1');
40418 add_option('default_link_category', 2);
40419 add_option('show_on_front', 'posts');
40420
40421 // 2.2
40422 add_option('tag_base');
40423
40424 // 2.5
40425 add_option('show_avatars', '1');
40426 add_option('avatar_rating', 'G');
40427 add_option('upload_url_path', '');
40428 add_option('thumbnail_size_w', 150);
40429 add_option('thumbnail_size_h', 150);
40430 add_option('thumbnail_crop', 1);
40431 add_option('medium_size_w', 300);
40432 add_option('medium_size_h', 300);
40433
40434 // 2.6
40435 add_option('avatar_default', 'mystery');
40436 add_option('enable_app', 0);
40437 add_option('enable_xmlrpc', 0);
40438
40439 // 2.7
40440 add_option('large_size_w', 1024);
40441 add_option('large_size_h', 1024);
40442 add_option('image_default_link_type', 'file');
40443 add_option('image_default_size', '');
40444 add_option('image_default_align', '');
40445 add_option('close_comments_for_old_posts', 0);
40446 add_option('close_comments_days_old', 14);
40447 add_option('thread_comments', 0);
40448 add_option('thread_comments_depth', 5);
40449 add_option('page_comments', 1);
40450 add_option('comments_per_page', 50);
40451 add_option('default_comments_page', 'newest');
40452 add_option('comment_order', 'asc');
40453 add_option('use_ssl', 0);
40454 add_option('sticky_posts', array());
40455 add_option('widget_categories', array());
40456 add_option('widget_text', array());
40457 add_option('widget_rss', array());
40458 add_option('update_core', array());
40459 add_option('dismissed_update_core', array());
40460
40461 // Delete unused options
40462 $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');
40463 foreach ($unusedoptions as $option) :
40464 delete_option($option);
40465 endforeach;
40466
40467 // Set up a few options not to load by default
40468 $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
40469 foreach ($fatoptions as $fatoption) :
40470 $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
40471 endforeach;
40472 }
40473
40474 /**
40475 * Execute WordPress role creation for the various WordPress versions.
40476 *
40477 * @since 2.0.0
40478 */
40479 function populate_roles() {
40480 populate_roles_160();
40481 populate_roles_210();
40482 populate_roles_230();
40483 populate_roles_250();
40484 populate_roles_260();
40485 populate_roles_270();
40486 }
40487
40488 /**
40489 * Create the roles for WordPress 2.0
40490 *
40491 * @since 2.0.0
40492 */
40493 function populate_roles_160() {
40494 // Add roles
40495
40496 // Dummy gettext calls to get strings in the catalog.
40497 _c('Administrator|User role');
40498 _c('Editor|User role');
40499 _c('Author|User role');
40500 _c('Contributor|User role');
40501 _c('Subscriber|User role');
40502
40503 add_role('administrator', 'Administrator|User role');
40504 add_role('editor', 'Editor|User role');
40505 add_role('author', 'Author|User role');
40506 add_role('contributor', 'Contributor|User role');
40507 add_role('subscriber', 'Subscriber|User role');
40508
40509 // Add caps for Administrator role
40510 $role = get_role('administrator');
40511 $role->add_cap('switch_themes');
40512 $role->add_cap('edit_themes');
40513 $role->add_cap('activate_plugins');
40514 $role->add_cap('edit_plugins');
40515 $role->add_cap('edit_users');
40516 $role->add_cap('edit_files');
40517 $role->add_cap('manage_options');
40518 $role->add_cap('moderate_comments');
40519 $role->add_cap('manage_categories');
40520 $role->add_cap('manage_links');
40521 $role->add_cap('upload_files');
40522 $role->add_cap('import');
40523 $role->add_cap('unfiltered_html');
40524 $role->add_cap('edit_posts');
40525 $role->add_cap('edit_others_posts');
40526 $role->add_cap('edit_published_posts');
40527 $role->add_cap('publish_posts');
40528 $role->add_cap('edit_pages');
40529 $role->add_cap('read');
40530 $role->add_cap('level_10');
40531 $role->add_cap('level_9');
40532 $role->add_cap('level_8');
40533 $role->add_cap('level_7');
40534 $role->add_cap('level_6');
40535 $role->add_cap('level_5');
40536 $role->add_cap('level_4');
40537 $role->add_cap('level_3');
40538 $role->add_cap('level_2');
40539 $role->add_cap('level_1');
40540 $role->add_cap('level_0');
40541
40542 // Add caps for Editor role
40543 $role = get_role('editor');
40544 $role->add_cap('moderate_comments');
40545 $role->add_cap('manage_categories');
40546 $role->add_cap('manage_links');
40547 $role->add_cap('upload_files');
40548 $role->add_cap('unfiltered_html');
40549 $role->add_cap('edit_posts');
40550 $role->add_cap('edit_others_posts');
40551 $role->add_cap('edit_published_posts');
40552 $role->add_cap('publish_posts');
40553 $role->add_cap('edit_pages');
40554 $role->add_cap('read');
40555 $role->add_cap('level_7');
40556 $role->add_cap('level_6');
40557 $role->add_cap('level_5');
40558 $role->add_cap('level_4');
40559 $role->add_cap('level_3');
40560 $role->add_cap('level_2');
40561 $role->add_cap('level_1');
40562 $role->add_cap('level_0');
40563
40564 // Add caps for Author role
40565 $role = get_role('author');
40566 $role->add_cap('upload_files');
40567 $role->add_cap('edit_posts');
40568 $role->add_cap('edit_published_posts');
40569 $role->add_cap('publish_posts');
40570 $role->add_cap('read');
40571 $role->add_cap('level_2');
40572 $role->add_cap('level_1');
40573 $role->add_cap('level_0');
40574
40575 // Add caps for Contributor role
40576 $role = get_role('contributor');
40577 $role->add_cap('edit_posts');
40578 $role->add_cap('read');
40579 $role->add_cap('level_1');
40580 $role->add_cap('level_0');
40581
40582 // Add caps for Subscriber role
40583 $role = get_role('subscriber');
40584 $role->add_cap('read');
40585 $role->add_cap('level_0');
40586 }
40587
40588 /**
40589 * Create and modify WordPress roles for WordPress 2.1.
40590 *
40591 * @since 2.1.0
40592 */
40593 function populate_roles_210() {
40594 $roles = array('administrator', 'editor');
40595 foreach ($roles as $role) {
40596 $role = get_role($role);
40597 if ( empty($role) )
40598 continue;
40599
40600 $role->add_cap('edit_others_pages');
40601 $role->add_cap('edit_published_pages');
40602 $role->add_cap('publish_pages');
40603 $role->add_cap('delete_pages');
40604 $role->add_cap('delete_others_pages');
40605 $role->add_cap('delete_published_pages');
40606 $role->add_cap('delete_posts');
40607 $role->add_cap('delete_others_posts');
40608 $role->add_cap('delete_published_posts');
40609 $role->add_cap('delete_private_posts');
40610 $role->add_cap('edit_private_posts');
40611 $role->add_cap('read_private_posts');
40612 $role->add_cap('delete_private_pages');
40613 $role->add_cap('edit_private_pages');
40614 $role->add_cap('read_private_pages');
40615 }
40616
40617 $role = get_role('administrator');
40618 if ( ! empty($role) ) {
40619 $role->add_cap('delete_users');
40620 $role->add_cap('create_users');
40621 }
40622
40623 $role = get_role('author');
40624 if ( ! empty($role) ) {
40625 $role->add_cap('delete_posts');
40626 $role->add_cap('delete_published_posts');
40627 }
40628
40629 $role = get_role('contributor');
40630 if ( ! empty($role) ) {
40631 $role->add_cap('delete_posts');
40632 }
40633 }
40634
40635 /**
40636 * Create and modify WordPress roles for WordPress 2.3.
40637 *
40638 * @since 2.3.0
40639 */
40640 function populate_roles_230() {
40641 $role = get_role( 'administrator' );
40642
40643 if ( !empty( $role ) ) {
40644 $role->add_cap( 'unfiltered_upload' );
40645 }
40646 }
40647
40648 /**
40649 * Create and modify WordPress roles for WordPress 2.5.
40650 *
40651 * @since 2.5.0
40652 */
40653 function populate_roles_250() {
40654 $role = get_role( 'administrator' );
40655
40656 if ( !empty( $role ) ) {
40657 $role->add_cap( 'edit_dashboard' );
40658 }
40659 }
40660
40661 /**
40662 * Create and modify WordPress roles for WordPress 2.6.
40663 *
40664 * @since 2.6.0
40665 */
40666 function populate_roles_260() {
40667 $role = get_role( 'administrator' );
40668
40669 if ( !empty( $role ) ) {
40670 $role->add_cap( 'update_plugins' );
40671 $role->add_cap( 'delete_plugins' );
40672 }
40673 }
40674
40675 /**
40676 * Create and modify WordPress roles for WordPress 2.7.
40677 *
40678 * @since 2.7.0
40679 */
40680 function populate_roles_270() {
40681 $role = get_role( 'administrator' );
40682
40683 if ( !empty( $role ) ) {
40684 $role->add_cap( 'install_plugins' );
40685 $role->add_cap( 'update_themes' );
40686 }
40687 }
40688
40689 ?>