PHP Cross Reference of WordPress Subversion HEAD

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]

title

Body

[close]

/wp-admin/includes/ -> schema.php (source)

   1  <?php
   2  // Here we keep the DB structure and option values
   3  
   4  $charset_collate = '';
   5  
   6  if ( $wpdb->supports_collation() ) {
   7      if ( ! empty($wpdb->charset) )
   8          $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
   9      if ( ! empty($wpdb->collate) )
  10          $charset_collate .= " COLLATE $wpdb->collate";
  11  }
  12  
  13  $wp_queries="CREATE TABLE $wpdb->terms (
  14   term_id bigint(20) NOT NULL auto_increment,
  15   name varchar(55) NOT NULL default '',
  16   slug varchar(200) NOT NULL default '',
  17   term_group bigint(10) NOT NULL default 0,
  18   PRIMARY KEY  (term_id),
  19   UNIQUE KEY slug (slug)
  20  ) $charset_collate;
  21  CREATE TABLE $wpdb->term_taxonomy (
  22   term_taxonomy_id bigint(20) NOT NULL auto_increment,
  23   term_id bigint(20) NOT NULL default 0,
  24   taxonomy varchar(32) NOT NULL default '',
  25   description longtext NOT NULL,
  26   parent bigint(20) NOT NULL default 0,
  27   count bigint(20) NOT NULL default 0,
  28   PRIMARY KEY  (term_taxonomy_id),
  29   UNIQUE KEY term_id_taxonomy (term_id,taxonomy)
  30  ) $charset_collate;
  31  CREATE TABLE $wpdb->term_relationships (
  32   object_id bigint(20) NOT NULL default 0,
  33   term_taxonomy_id bigint(20) NOT NULL default 0,
  34   PRIMARY KEY  (object_id,term_taxonomy_id),
  35   KEY term_taxonomy_id (term_taxonomy_id)
  36  ) $charset_collate;
  37  CREATE TABLE $wpdb->comments (
  38    comment_ID bigint(20) unsigned NOT NULL auto_increment,
  39    comment_post_ID int(11) NOT NULL default '0',
  40    comment_author tinytext NOT NULL,
  41    comment_author_email varchar(100) NOT NULL default '',
  42    comment_author_url varchar(200) NOT NULL default '',
  43    comment_author_IP varchar(100) NOT NULL default '',
  44    comment_date datetime NOT NULL default '0000-00-00 00:00:00',
  45    comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  46    comment_content text NOT NULL,
  47    comment_karma int(11) NOT NULL default '0',
  48    comment_approved enum('0','1','spam') NOT NULL default '1',
  49    comment_agent varchar(255) NOT NULL default '',
  50    comment_type varchar(20) NOT NULL default '',
  51    comment_parent bigint(20) NOT NULL default '0',
  52    user_id bigint(20) NOT NULL default '0',
  53    PRIMARY KEY  (comment_ID),
  54    KEY comment_approved (comment_approved),
  55    KEY comment_post_ID (comment_post_ID)
  56  ) $charset_collate;
  57  CREATE TABLE $wpdb->links (
  58    link_id bigint(20) NOT NULL auto_increment,
  59    link_url varchar(255) NOT NULL default '',
  60    link_name varchar(255) NOT NULL default '',
  61    link_image varchar(255) NOT NULL default '',
  62    link_target varchar(25) NOT NULL default '',
  63    link_category bigint(20) NOT NULL default '0',
  64    link_description varchar(255) NOT NULL default '',
  65    link_visible enum('Y','N') NOT NULL default 'Y',
  66    link_owner int(11) NOT NULL default '1',
  67    link_rating int(11) NOT NULL default '0',
  68    link_updated datetime NOT NULL default '0000-00-00 00:00:00',
  69    link_rel varchar(255) NOT NULL default '',
  70    link_notes mediumtext NOT NULL,
  71    link_rss varchar(255) NOT NULL default '',
  72    PRIMARY KEY  (link_id),
  73    KEY link_category (link_category),
  74    KEY link_visible (link_visible)
  75  ) $charset_collate;
  76  CREATE TABLE $wpdb->options (
  77    option_id bigint(20) NOT NULL auto_increment,
  78    blog_id int(11) NOT NULL default '0',
  79    option_name varchar(64) NOT NULL default '',
  80    option_value longtext NOT NULL,
  81    autoload enum('yes','no') NOT NULL default 'yes',
  82    PRIMARY KEY  (option_id,blog_id,option_name),
  83    KEY option_name (option_name)
  84  ) $charset_collate;
  85  CREATE TABLE $wpdb->postmeta (
  86    meta_id bigint(20) NOT NULL auto_increment,
  87    post_id bigint(20) NOT NULL default '0',
  88    meta_key varchar(255) default NULL,
  89    meta_value longtext,
  90    PRIMARY KEY  (meta_id),
  91    KEY post_id (post_id),
  92    KEY meta_key (meta_key)
  93  ) $charset_collate;
  94  CREATE TABLE $wpdb->posts (
  95    ID bigint(20) unsigned NOT NULL auto_increment,
  96    post_author bigint(20) NOT NULL default '0',
  97    post_date datetime NOT NULL default '0000-00-00 00:00:00',
  98    post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
  99    post_content longtext NOT NULL,
 100    post_title text NOT NULL,
 101    post_category int(4) NOT NULL default '0',
 102    post_excerpt text NOT NULL,
 103    post_status enum('publish','draft','private','static','object','attachment','inherit','future', 'pending') NOT NULL default 'publish',
 104    comment_status enum('open','closed','registered_only') NOT NULL default 'open',
 105    ping_status enum('open','closed') NOT NULL default 'open',
 106    post_password varchar(20) NOT NULL default '',
 107    post_name varchar(200) NOT NULL default '',
 108    to_ping text NOT NULL,
 109    pinged text NOT NULL,
 110    post_modified datetime NOT NULL default '0000-00-00 00:00:00',
 111    post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
 112    post_content_filtered text NOT NULL,
 113    post_parent bigint(20) NOT NULL default '0',
 114    guid varchar(255) NOT NULL default '',
 115    menu_order int(11) NOT NULL default '0',
 116    post_type varchar(20) NOT NULL default 'post',
 117    post_mime_type varchar(100) NOT NULL default '',
 118    comment_count bigint(20) NOT NULL default '0',
 119    PRIMARY KEY  (ID),
 120    KEY post_name (post_name),
 121    KEY type_status_date (post_type,post_status,post_date,ID)
 122  ) $charset_collate;
 123  CREATE TABLE $wpdb->users (
 124    ID bigint(20) unsigned NOT NULL auto_increment,
 125    user_login varchar(60) NOT NULL default '',
 126    user_pass varchar(64) NOT NULL default '',
 127    user_nicename varchar(50) NOT NULL default '',
 128    user_email varchar(100) NOT NULL default '',
 129    user_url varchar(100) NOT NULL default '',
 130    user_registered datetime NOT NULL default '0000-00-00 00:00:00',
 131    user_activation_key varchar(60) NOT NULL default '',
 132    user_status int(11) NOT NULL default '0',
 133    display_name varchar(250) NOT NULL default '',
 134    PRIMARY KEY  (ID),
 135    KEY user_login_key (user_login),
 136    KEY user_nicename (user_nicename)
 137  ) $charset_collate;
 138  CREATE TABLE $wpdb->usermeta (
 139    umeta_id bigint(20) NOT NULL auto_increment,
 140    user_id bigint(20) NOT NULL default '0',
 141    meta_key varchar(255) default NULL,
 142    meta_value longtext,
 143    PRIMARY KEY  (umeta_id),
 144    KEY user_id (user_id),
 145    KEY meta_key (meta_key)
 146  ) $charset_collate;";
 147  
 148  function populate_options() {
 149      global $wpdb, $wp_db_version;
 150  
 151      $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
 152      $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 153      add_option('siteurl', $guessurl);
 154      add_option('blogname', __('My Blog'));
 155      add_option('blogdescription', __('Just another WordPress weblog'));
 156      add_option('users_can_register', 0);
 157      add_option('admin_email', 'you@example.com');
 158      add_option('start_of_week', 1);
 159      add_option('use_balanceTags', 0);
 160      add_option('use_smilies', 1);
 161      add_option('require_name_email', 1);
 162      add_option('comments_notify', 1);
 163      add_option('posts_per_rss', 10);
 164      add_option('rss_excerpt_length', 50);
 165      add_option('rss_use_excerpt', 0);
 166      add_option('mailserver_url', 'mail.example.com');
 167      add_option('mailserver_login', 'login@example.com');
 168      add_option('mailserver_pass', 'password');
 169      add_option('mailserver_port', 110);
 170      add_option('default_category', 1);
 171      add_option('default_comment_status', 'open');
 172      add_option('default_ping_status', 'open');
 173      add_option('default_pingback_flag', 1);
 174      add_option('default_post_edit_rows', 10);
 175      add_option('posts_per_page', 10);
 176      add_option('what_to_show', 'posts');
 177      add_option('date_format', __('F j, Y'));
 178      add_option('time_format', __('g:i a'));
 179      add_option('links_updated_date_format', __('F j, Y g:i a'));
 180      add_option('links_recently_updated_prepend', '<em>');
 181      add_option('links_recently_updated_append', '</em>');
 182      add_option('links_recently_updated_time', 120);
 183      add_option('comment_moderation', 0);
 184      add_option('moderation_notify', 1);
 185      add_option('permalink_structure');
 186      add_option('gzipcompression', 0);
 187      add_option('hack_file', 0);
 188      add_option('blog_charset', 'UTF-8');
 189      add_option('moderation_keys');
 190      add_option('active_plugins');
 191      add_option('home', $guessurl);
 192      // in case it is set, but blank, update "home"
 193      if ( !__get_option('home') ) update_option('home', $guessurl);
 194      add_option('category_base');
 195      add_option('ping_sites', 'http://rpc.pingomatic.com/');
 196      add_option('advanced_edit', 0);
 197      add_option('comment_max_links', 2);
 198      add_option('gmt_offset', date('Z') / 3600);
 199      // 1.5
 200      add_option('default_email_category', 1);
 201      add_option('recently_edited');
 202      add_option('use_linksupdate', 0);
 203      add_option('template', 'default');
 204      add_option('stylesheet', 'default');
 205      add_option('comment_whitelist', 1);
 206      add_option('page_uris');
 207      add_option('blacklist_keys');
 208      add_option('comment_registration', 0);
 209      add_option('rss_language', 'en');
 210      add_option('html_type', 'text/html');
 211      // 1.5.1
 212      add_option('use_trackback', 0);
 213      // 2.0
 214      add_option('default_role', 'subscriber');
 215      add_option('db_version', $wp_db_version);
 216      // 2.0.1
 217      if ( ini_get('safe_mode') ) {
 218          // Safe mode screws up mkdir(), so we must use a flat structure.
 219          add_option('uploads_use_yearmonth_folders', 0);
 220          add_option('upload_path', 'wp-content');
 221      } else {
 222          add_option('uploads_use_yearmonth_folders', 1);
 223          add_option('upload_path', 'wp-content/uploads');
 224      }
 225  
 226      // 2.0.3
 227      add_option('secret', md5(uniqid(microtime())));
 228  
 229      // 2.1
 230      add_option('blog_public', '1');
 231      add_option('default_link_category', 2);
 232      add_option('show_on_front', 'posts');
 233  
 234      // 2.2
 235      add_option('tag_base');
 236  
 237      // Delete unused options
 238      $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');
 239      foreach ($unusedoptions as $option) :
 240          delete_option($option);
 241      endforeach;
 242  
 243      // Set up a few options not to load by default
 244      $fatoptions = array( 'moderation_keys', 'recently_edited', 'blacklist_keys' );
 245      foreach ($fatoptions as $fatoption) :
 246          $wpdb->query("UPDATE $wpdb->options SET `autoload` = 'no' WHERE option_name = '$fatoption'");
 247      endforeach;
 248  }
 249  
 250  function populate_roles() {
 251      populate_roles_160();
 252      populate_roles_210();
 253      populate_roles_230();
 254  }
 255  
 256  function populate_roles_160() {
 257      // Add roles
 258      add_role('administrator', _c('Administrator|User role'));
 259      add_role('editor', _c('Editor|User role'));
 260      add_role('author', _c('Author|User role'));
 261      add_role('contributor', _c('Contributor|User role'));
 262      add_role('subscriber', _c('Subscriber|User role'));
 263  
 264      // Add caps for Administrator role
 265      $role = get_role('administrator');
 266      $role->add_cap('switch_themes');
 267      $role->add_cap('edit_themes');
 268      $role->add_cap('activate_plugins');
 269      $role->add_cap('edit_plugins');
 270      $role->add_cap('edit_users');
 271      $role->add_cap('edit_files');
 272      $role->add_cap('manage_options');
 273      $role->add_cap('moderate_comments');
 274      $role->add_cap('manage_categories');
 275      $role->add_cap('manage_links');
 276      $role->add_cap('upload_files');
 277      $role->add_cap('import');
 278      $role->add_cap('unfiltered_html');
 279      $role->add_cap('edit_posts');
 280      $role->add_cap('edit_others_posts');
 281      $role->add_cap('edit_published_posts');
 282      $role->add_cap('publish_posts');
 283      $role->add_cap('edit_pages');
 284      $role->add_cap('read');
 285      $role->add_cap('level_10');
 286      $role->add_cap('level_9');
 287      $role->add_cap('level_8');
 288      $role->add_cap('level_7');
 289      $role->add_cap('level_6');
 290      $role->add_cap('level_5');
 291      $role->add_cap('level_4');
 292      $role->add_cap('level_3');
 293      $role->add_cap('level_2');
 294      $role->add_cap('level_1');
 295      $role->add_cap('level_0');
 296  
 297      // Add caps for Editor role
 298      $role = get_role('editor');
 299      $role->add_cap('moderate_comments');
 300      $role->add_cap('manage_categories');
 301      $role->add_cap('manage_links');
 302      $role->add_cap('upload_files');
 303      $role->add_cap('unfiltered_html');
 304      $role->add_cap('edit_posts');
 305      $role->add_cap('edit_others_posts');
 306      $role->add_cap('edit_published_posts');
 307      $role->add_cap('publish_posts');
 308      $role->add_cap('edit_pages');
 309      $role->add_cap('read');
 310      $role->add_cap('level_7');
 311      $role->add_cap('level_6');
 312      $role->add_cap('level_5');
 313      $role->add_cap('level_4');
 314      $role->add_cap('level_3');
 315      $role->add_cap('level_2');
 316      $role->add_cap('level_1');
 317      $role->add_cap('level_0');
 318  
 319      // Add caps for Author role
 320      $role = get_role('author');
 321      $role->add_cap('upload_files');
 322      $role->add_cap('edit_posts');
 323      $role->add_cap('edit_published_posts');
 324      $role->add_cap('publish_posts');
 325      $role->add_cap('read');
 326      $role->add_cap('level_2');
 327      $role->add_cap('level_1');
 328      $role->add_cap('level_0');
 329  
 330      // Add caps for Contributor role
 331      $role = get_role('contributor');
 332      $role->add_cap('edit_posts');
 333      $role->add_cap('read');
 334      $role->add_cap('level_1');
 335      $role->add_cap('level_0');
 336  
 337      // Add caps for Subscriber role
 338      $role = get_role('subscriber');
 339      $role->add_cap('read');
 340      $role->add_cap('level_0');
 341  }
 342  
 343  function populate_roles_210() {
 344      $roles = array('administrator', 'editor');
 345      foreach ($roles as $role) {
 346          $role = get_role($role);
 347          if ( empty($role) )
 348              continue;
 349  
 350          $role->add_cap('edit_others_pages');
 351          $role->add_cap('edit_published_pages');
 352          $role->add_cap('publish_pages');
 353          $role->add_cap('delete_pages');
 354          $role->add_cap('delete_others_pages');
 355          $role->add_cap('delete_published_pages');
 356          $role->add_cap('delete_posts');
 357          $role->add_cap('delete_others_posts');
 358          $role->add_cap('delete_published_posts');
 359          $role->add_cap('delete_private_posts');
 360          $role->add_cap('edit_private_posts');
 361          $role->add_cap('read_private_posts');
 362          $role->add_cap('delete_private_pages');
 363          $role->add_cap('edit_private_pages');
 364          $role->add_cap('read_private_pages');
 365      }
 366  
 367      $role = get_role('administrator');
 368      if ( ! empty($role) ) {
 369          $role->add_cap('delete_users');
 370          $role->add_cap('create_users');
 371      }
 372  
 373      $role = get_role('author');
 374      if ( ! empty($role) ) {
 375          $role->add_cap('delete_posts');
 376          $role->add_cap('delete_published_posts');
 377      }
 378  
 379      $role = get_role('contributor');
 380      if ( ! empty($role) ) {
 381          $role->add_cap('delete_posts');
 382      }
 383  }
 384  
 385  function populate_roles_230() {
 386      $role = get_role( 'administrator' );
 387  
 388      if ( !empty( $role ) ) {
 389          $role->add_cap( 'unfiltered_upload' );
 390      }
 391  }
 392  
 393  ?>


Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs Cross-referenced by PHPXref 0.6 and RedAlt