Make WordPress Core


Ignore:
Timestamp:
05/24/2004 08:22:18 AM (21 years ago)
Author:
saxmatt
Message:

Giant commit, sorry mailing list people. Move all table names to new $wpdb versions. Works but the whole app needs thorough testing now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-functions.php

    r1325 r1355  
    7676
    7777function upgrade_071() {
    78     global $tableposts;
    79     maybe_add_column($tableposts, 'post_status', "ALTER TABLE $tableposts ADD `post_status` ENUM('publish','draft','private') NOT NULL");
    80     maybe_add_column($tableposts, 'comment_status', "ALTER TABLE $tableposts ADD `comment_status` ENUM('open','closed') NOT NULL");
    81     maybe_add_column($tableposts, 'ping_status', "ALTER TABLE $tableposts ADD `ping_status` ENUM('open','closed') NOT NULL");
    82     maybe_add_column($tableposts, 'post_password', "ALTER TABLE $tableposts ADD post_password varchar(20) NOT NULL");
     78    global $wpdb;
     79    maybe_add_column($wpdb->posts, 'post_status', "ALTER TABLE $wpdb->posts ADD `post_status` ENUM('publish','draft','private') NOT NULL");
     80    maybe_add_column($wpdb->posts, 'comment_status', "ALTER TABLE $wpdb->posts ADD `comment_status` ENUM('open','closed') NOT NULL");
     81    maybe_add_column($wpdb->posts, 'ping_status', "ALTER TABLE $wpdb->posts ADD `ping_status` ENUM('open','closed') NOT NULL");
     82    maybe_add_column($wpdb->posts, 'post_password', "ALTER TABLE $wpdb->posts ADD post_password varchar(20) NOT NULL");
    8383}
    8484
    8585function upgrade_072() {
    86     global $wpdb, $tableposts, $tablelinks, $tablelinkcategories, $tableoptions, $tableoptiontypes, $tableoptiongroups, $tableoptiongroup_options, $tableoptionvalues, $tablecategories;
    87     maybe_add_column($tablelinks, 'link_notes', "ALTER TABLE $tablelinks ADD COLUMN link_notes MEDIUMTEXT NOT NULL DEFAULT '' ");
    88     maybe_add_column($tablelinkcategories, 'show_images', "ALTER TABLE $tablelinkcategories ADD COLUMN show_images enum('Y','N') NOT NULL default 'Y'");
    89     maybe_add_column($tablelinkcategories, 'show_description', "ALTER TABLE $tablelinkcategories ADD COLUMN show_description enum('Y','N') NOT NULL default 'Y'");
    90     maybe_add_column($tablelinkcategories, 'show_rating', "ALTER TABLE $tablelinkcategories ADD COLUMN show_rating enum('Y','N') NOT NULL default 'Y'");
    91     maybe_add_column($tablelinkcategories, 'show_updated', "ALTER TABLE $tablelinkcategories ADD COLUMN show_updated enum('Y','N') NOT NULL default 'Y'");
    92     maybe_add_column($tablelinkcategories, 'sort_order', "ALTER TABLE $tablelinkcategories ADD COLUMN sort_order varchar(64) NOT NULL default 'name'");
    93     maybe_add_column($tablelinkcategories, 'sort_desc', "ALTER TABLE $tablelinkcategories ADD COLUMN sort_desc enum('Y','N') NOT NULL default 'N'");
    94     maybe_add_column($tablelinkcategories, 'text_before_link', "ALTER TABLE $tablelinkcategories ADD COLUMN text_before_link varchar(128) not null default '<li>'");
    95     maybe_add_column($tablelinkcategories, 'text_after_link', "ALTER TABLE $tablelinkcategories ADD COLUMN text_after_link  varchar(128) not null default '<br />'");
    96     maybe_add_column($tablelinkcategories, 'text_after_all', "ALTER TABLE $tablelinkcategories ADD COLUMN text_after_all  varchar(128) not null default '</li>'");
    97     maybe_add_column($tablelinkcategories, 'list_limit', "ALTER TABLE $tablelinkcategories ADD COLUMN list_limit int not null default -1");
    98     maybe_add_column($tableposts, 'post_lon', "ALTER TABLE $tableposts ADD COLUMN post_lon float");
    99     maybe_add_column($tableposts, 'post_lat', "ALTER TABLE $tableposts ADD COLUMN post_lat float ");
    100     maybe_create_table($tableoptions, "
    101     CREATE TABLE $tableoptions (
     86    global $wpdb;
     87    maybe_add_column($wpdb->links, 'link_notes', "ALTER TABLE $wpdb->links ADD COLUMN link_notes MEDIUMTEXT NOT NULL DEFAULT '' ");
     88    maybe_add_column($wpdb->links, 'show_images', "ALTER TABLE $wpdb->linkcategories ADD COLUMN show_images enum('Y','N') NOT NULL default 'Y'");
     89    maybe_add_column($wpdb->links, 'show_description', "ALTER TABLE $wpdb->linkcategories ADD COLUMN show_description enum('Y','N') NOT NULL default 'Y'");
     90    maybe_add_column($wpdb->links, 'show_rating', "ALTER TABLE $wpdb->linkcategories ADD COLUMN show_rating enum('Y','N') NOT NULL default 'Y'");
     91    maybe_add_column($wpdb->links, 'show_updated', "ALTER TABLE $wpdb->linkcategories ADD COLUMN show_updated enum('Y','N') NOT NULL default 'Y'");
     92    maybe_add_column($wpdb->links, 'sort_order', "ALTER TABLE $wpdb->linkcategories ADD COLUMN sort_order varchar(64) NOT NULL default 'name'");
     93    maybe_add_column($wpdb->linkcategories, 'sort_desc', "ALTER TABLE $wpdb->linkcategories ADD COLUMN sort_desc enum('Y','N') NOT NULL default 'N'");
     94    maybe_add_column($wpdb->linkcategories, 'text_before_link', "ALTER TABLE $wpdb->linkcategories ADD COLUMN text_before_link varchar(128) not null default '<li>'");
     95    maybe_add_column($wpdb->linkcategories, 'text_after_link', "ALTER TABLE $wpdb->linkcategories ADD COLUMN text_after_link  varchar(128) not null default '<br />'");
     96    maybe_add_column($wpdb->linkcategories, 'text_after_all', "ALTER TABLE $wpdb->linkcategories ADD COLUMN text_after_all  varchar(128) not null default '</li>'");
     97    maybe_add_column($wpdb->linkcategories, 'list_limit', "ALTER TABLE $wpdb->linkcategories ADD COLUMN list_limit int not null default -1");
     98    maybe_add_column($wpdb->posts, 'post_lon', "ALTER TABLE $wpdb->posts ADD COLUMN post_lon float");
     99    maybe_add_column($wpdb->posts, 'post_lat', "ALTER TABLE $wpdb->posts ADD COLUMN post_lat float ");
     100    maybe_create_table($wpdb->options, "
     101    CREATE TABLE $wpdb->options (
    102102      option_id int(11) NOT NULL auto_increment,
    103103      blog_id int(11) NOT NULL default 0,
     
    113113    )
    114114    ");
    115     maybe_create_table($tableoptiontypes, "
    116     CREATE TABLE $tableoptiontypes (
     115    maybe_create_table($wpdb->optiontypes, "
     116    CREATE TABLE $wpdb->optiontypes (
    117117      optiontype_id int(11) NOT NULL auto_increment,
    118118      optiontype_name varchar(64) NOT NULL,
     
    120120    )
    121121    ");
    122     maybe_create_table($tableoptiongroups, "
    123     CREATE TABLE $tableoptiongroups (
     122    maybe_create_table($wpdb->optiongroups, "
     123    CREATE TABLE $wpdb->optiongroups (
    124124      group_id int(11) NOT NULL auto_increment,
    125125      group_name varchar(64) not null,
     
    129129    )
    130130    ");
    131     maybe_create_table($tableoptiongroup_options, "
    132     CREATE TABLE $tableoptiongroup_options (
     131    maybe_create_table($wpdb->optiongroup_options, "
     132    CREATE TABLE $wpdb->optiongroup_options (
    133133      group_id int(11) NOT NULL,
    134134      option_id int(11) NOT NULL,
     
    137137    )
    138138    ");
    139     maybe_create_table($tableoptionvalues, "
    140     CREATE TABLE $tableoptionvalues (
     139    maybe_create_table($wpdb->optionvalues, "
     140    CREATE TABLE $wpdb->optionvalues (
    141141      option_id int(11) NOT NULL,
    142142      optionvalue tinytext,
     
    152152    // TODO: REWRITE THIS
    153153    $option_types = array(
    154         "1" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('1', 'integer')",
    155         "2" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('2', 'boolean')",
    156         "3" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('3', 'string')",
    157         "4" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('4', 'date')",
    158         "5" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('5', 'select')",
    159         "6" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('6', 'range')",
    160         "7" => "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES ('7', 'sqlselect')");
     154        "1" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('1', 'integer')",
     155        "2" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('2', 'boolean')",
     156        "3" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('3', 'string')",
     157        "4" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('4', 'date')",
     158        "5" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('5', 'select')",
     159        "6" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('6', 'range')",
     160        "7" => "INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES ('7', 'sqlselect')");
    161161
    162162    foreach ($option_types as $option_id => $query) {
    163         if(!$wpdb->get_var("SELECT * FROM $tableoptiontypes WHERE optiontype_id = '$option_id'")) {
     163        if(!$wpdb->get_var("SELECT * FROM $wpdb->optiontypes WHERE optiontype_id = '$option_id'")) {
    164164            $wpdb->query($query);
    165165        }
     
    169169$guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $HTTP_HOST . $REQUEST_URI);
    170170    $option_data = array(       //base options from b2cofig
    171         "1" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (1,'siteurl', 3, '$guessurl', 'siteurl is your blog\'s URL: for example, \'http://example.com/wordpress\'', 8, 30)",
    172         "2" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (2,'blogfilename', 3, 'index.php', 'blogfilename is the name of the default file for your blog', 8, 20)",
    173         "3" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (3,'blogname', 3, 'my weblog', 'blogname is the name of your blog', 8, 20)",
    174         "4" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (4,'blogdescription', 3, 'babblings!', 'blogdescription is the description of your blog', 8, 40)",
    175         //"INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (6,'search_engine_friendly_urls', 2, '0', 'Querystring Configuration ** (don\'t change if you don\'t know what you\'re doing)', 8, 20)",
    176         "7" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (7,'new_users_can_blog', 2, '0', 'whether you want new users to be able to post entries once they have registered', 8, 20)",
    177         "8" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (8,'users_can_register', 2, '1', 'whether you want to allow users to register on your blog', 8, 20)",
    178         "54" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (54,'admin_email', 3, 'you@example.com', 'Your email (obvious eh?)', 8, 20)",
     171        "1" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (1,'siteurl', 3, '$guessurl', 'siteurl is your blog\'s URL: for example, \'http://example.com/wordpress\'', 8, 30)",
     172        "2" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (2,'blogfilename', 3, 'index.php', 'blogfilename is the name of the default file for your blog', 8, 20)",
     173        "3" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (3,'blogname', 3, 'my weblog', 'blogname is the name of your blog', 8, 20)",
     174        "4" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (4,'blogdescription', 3, 'babblings!', 'blogdescription is the description of your blog', 8, 40)",
     175        //"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (6,'search_engine_friendly_urls', 2, '0', 'Querystring Configuration ** (don\'t change if you don\'t know what you\'re doing)', 8, 20)",
     176        "7" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (7,'new_users_can_blog', 2, '0', 'whether you want new users to be able to post entries once they have registered', 8, 20)",
     177        "8" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (8,'users_can_register', 2, '1', 'whether you want to allow users to register on your blog', 8, 20)",
     178        "54" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (54,'admin_email', 3, 'you@example.com', 'Your email (obvious eh?)', 8, 20)",
    179179        // general blog setup
    180         "9" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (9 ,'start_of_week', 5, '1', 'day at the start of the week', 8, 20)",
    181         //"INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (10,'use_preview', 2, '1', 'Do you want to use the \'preview\' function', 8, 20)",
    182         "14" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (14,'use_htmltrans', 2, '1', 'IMPORTANT! set this to false if you are using Chinese, Japanese, Korean, or other double-bytes languages', 8, 20)",
    183         "15" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (15,'use_balanceTags', 2, '1', 'this could help balance your HTML code. if it gives bad results, set it to false', 8, 20)",
    184         "16" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (16,'use_smilies', 2, '1', 'set this to true to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8, 20)",
    185         "17" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (17,'smilies_directory', 3, 'http://example.com/wp-images/smilies', 'the directory where your smilies are (no trailing slash)', 8, 40)",
    186         "18" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (18,'require_name_email', 2, '0', 'set this to true to require e-mail and name, or false to allow comments without e-mail/name', 8, 20)",
    187         "20" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (20,'comments_notify', 2, '1', 'set this to true to let every author be notified about comments on their posts', 8, 20)",
     180        "9" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (9 ,'start_of_week', 5, '1', 'day at the start of the week', 8, 20)",
     181        //"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (10,'use_preview', 2, '1', 'Do you want to use the \'preview\' function', 8, 20)",
     182        "14" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (14,'use_htmltrans', 2, '1', 'IMPORTANT! set this to false if you are using Chinese, Japanese, Korean, or other double-bytes languages', 8, 20)",
     183        "15" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (15,'use_balanceTags', 2, '1', 'this could help balance your HTML code. if it gives bad results, set it to false', 8, 20)",
     184        "16" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (16,'use_smilies', 2, '1', 'set this to true to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8, 20)",
     185        "17" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (17,'smilies_directory', 3, 'http://example.com/wp-images/smilies', 'the directory where your smilies are (no trailing slash)', 8, 40)",
     186        "18" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (18,'require_name_email', 2, '0', 'set this to true to require e-mail and name, or false to allow comments without e-mail/name', 8, 20)",
     187        "20" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (20,'comments_notify', 2, '1', 'set this to true to let every author be notified about comments on their posts', 8, 20)",
    188188        //rss/rdf feeds
    189         "21" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (21,'posts_per_rss', 1, '10', 'number of last posts to syndicate', 8, 20)",
    190         "22" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (22,'rss_language', 3, 'en', 'the language of your blog ( see this: http://backend.userland.com/stories/storyReader$16 )', 8, 20)",
    191         "23" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (23,'rss_encoded_html', 2, '0', 'for b2rss.php: allow encoded HTML in &lt;description> tag?', 8, 20)",
    192         "24" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (24,'rss_excerpt_length', 1, '50', 'length (in words) of excerpts in the RSS feed? 0=unlimited note: in b2rss.php, this will be set to 0 if you use encoded HTML', 8, 20)",
    193         "25" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (25,'rss_use_excerpt', 2, '1', 'use the excerpt field for rss feed.', 8, 20)",
    194         "29" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (29,'use_trackback', 2, '1', 'set this to false or true, whether you want to allow your posts to be trackback\'able or not note: setting it to false would also disable sending trackbacks', 8, 20)",
    195         "30" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (30,'use_pingback', 2, '1', 'set this to false or true, whether you want to allow your posts to be pingback\'able or not note: setting it to false would also disable sending pingbacks', 8, 20)",
     189        "21" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (21,'posts_per_rss', 1, '10', 'number of last posts to syndicate', 8, 20)",
     190        "22" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (22,'rss_language', 3, 'en', 'the language of your blog ( see this: http://backend.userland.com/stories/storyReader$16 )', 8, 20)",
     191        "23" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (23,'rss_encoded_html', 2, '0', 'for b2rss.php: allow encoded HTML in &lt;description> tag?', 8, 20)",
     192        "24" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (24,'rss_excerpt_length', 1, '50', 'length (in words) of excerpts in the RSS feed? 0=unlimited note: in b2rss.php, this will be set to 0 if you use encoded HTML', 8, 20)",
     193        "25" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (25,'rss_use_excerpt', 2, '1', 'use the excerpt field for rss feed.', 8, 20)",
     194        "29" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (29,'use_trackback', 2, '1', 'set this to false or true, whether you want to allow your posts to be trackback\'able or not note: setting it to false would also disable sending trackbacks', 8, 20)",
     195        "30" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (30,'use_pingback', 2, '1', 'set this to false or true, whether you want to allow your posts to be pingback\'able or not note: setting it to false would also disable sending pingbacks', 8, 20)",
    196196        //file upload
    197         "31" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (31,'use_fileupload', 2, '0', 'set this to false to disable file upload, or true to enable it', 8, 20)",
    198         "32" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (32,'fileupload_realpath', 3, '/home/your/site/wordpress/images', 'enter the real path of the directory where you\'ll upload the pictures \nif you\'re unsure about what your real path is, please ask your host\'s support staff \nnote that the  directory must be writable by the webserver (chmod 766) \nnote for windows-servers users: use forwardslashes instead of backslashes', 8, 40)",
    199         "33" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (33,'fileupload_url', 3, 'http://example.com/images', 'enter the URL of that directory (it\'s used to generate the links to the uploded files)', 8, 40)",
    200         "34" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (34,'fileupload_allowedtypes', 3, ' jpg gif png ', 'accepted file types, separated by spaces. example: \'jpg gif png\'', 8, 20)",
    201         "35" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (35,'fileupload_maxk', 1, '96', 'by default, most servers limit the size of uploads to 2048 KB, if you want to set it to a lower value, here it is (you cannot set a higher value than your server limit)', 8, 20)",
    202         "36" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (36,'fileupload_minlevel', 1, '1', 'you may not want all users to upload pictures/files, so you can set a minimum level for this', 8, 20)",
    203         "37" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (37,'fileupload_allowedusers', 3, '', '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'', 8, 30)",
     197        "31" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (31,'use_fileupload', 2, '0', 'set this to false to disable file upload, or true to enable it', 8, 20)",
     198        "32" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (32,'fileupload_realpath', 3, '/home/your/site/wordpress/images', 'enter the real path of the directory where you\'ll upload the pictures \nif you\'re unsure about what your real path is, please ask your host\'s support staff \nnote that the  directory must be writable by the webserver (chmod 766) \nnote for windows-servers users: use forwardslashes instead of backslashes', 8, 40)",
     199        "33" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (33,'fileupload_url', 3, 'http://example.com/images', 'enter the URL of that directory (it\'s used to generate the links to the uploded files)', 8, 40)",
     200        "34" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (34,'fileupload_allowedtypes', 3, ' jpg gif png ', 'accepted file types, separated by spaces. example: \'jpg gif png\'', 8, 20)",
     201        "35" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (35,'fileupload_maxk', 1, '96', 'by default, most servers limit the size of uploads to 2048 KB, if you want to set it to a lower value, here it is (you cannot set a higher value than your server limit)', 8, 20)",
     202        "36" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (36,'fileupload_minlevel', 1, '1', 'you may not want all users to upload pictures/files, so you can set a minimum level for this', 8, 20)",
     203        "37" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (37,'fileupload_allowedusers', 3, '', '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'', 8, 30)",
    204204        // email settings
    205         "38" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (38,'mailserver_url', 3, 'mail.example.com', 'mailserver settings', 8, 20)",
    206         "39" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (39,'mailserver_login', 3, 'login@example.com', 'mailserver settings', 8, 20)",
    207         "40" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (40,'mailserver_pass', 3, 'password', 'mailserver settings', 8, 20)",
    208         "41" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (41,'mailserver_port', 1, '110', 'mailserver settings', 8, 20)",
    209         "42" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (42,'default_category', 1, '1', 'by default posts will have this category', 8, 20)",
    210         "46" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (46,'use_phoneemail', 2, '0', 'some mobile phone email services will send identical subject & content on the same line if you use such a service, set use_phoneemail to true, and indicate a separator string', 8, 20)",
     205        "38" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (38,'mailserver_url', 3, 'mail.example.com', 'mailserver settings', 8, 20)",
     206        "39" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (39,'mailserver_login', 3, 'login@example.com', 'mailserver settings', 8, 20)",
     207        "40" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (40,'mailserver_pass', 3, 'password', 'mailserver settings', 8, 20)",
     208        "41" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (41,'mailserver_port', 1, '110', 'mailserver settings', 8, 20)",
     209        "42" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (42,'default_category', 1, '1', 'by default posts will have this category', 8, 20)",
     210        "46" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (46,'use_phoneemail', 2, '0', 'some mobile phone email services will send identical subject & content on the same line if you use such a service, set use_phoneemail to true, and indicate a separator string', 8, 20)",
    211211       
    212212        // default post stuff
    213213       
    214         "55" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(55,'default_post_status',    5, 'publish', 'The default state of each new post', 8, 20)",
    215         "56" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(56,'default_comment_status', 5, 'open', 'The default state of comments for each new post', 8, 20)",
    216         "57" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(57,'default_ping_status',    5, 'open', 'The default ping state for each new post', 8, 20)",
    217         "58" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(58,'default_pingback_flag',  5, '1', 'Whether the \'PingBack the URLs in this post\' checkbox should be checked by default', 8, 20)",
    218         "59" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(59,'default_post_category',  7, '1', 'The default category for each new post', 8, 20)",
    219         "83" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(83,'default_post_edit_rows', 1, '9', 'The number of rows in the edit post form (min 3, max 100)', 8, 5)",
     214        "55" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(55,'default_post_status',    5, 'publish', 'The default state of each new post', 8, 20)",
     215        "56" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(56,'default_comment_status', 5, 'open', 'The default state of comments for each new post', 8, 20)",
     216        "57" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(57,'default_ping_status',    5, 'open', 'The default ping state for each new post', 8, 20)",
     217        "58" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(58,'default_pingback_flag',  5, '1', 'Whether the \'PingBack the URLs in this post\' checkbox should be checked by default', 8, 20)",
     218        "59" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(59,'default_post_category',  7, '1', 'The default category for each new post', 8, 20)",
     219        "83" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(83,'default_post_edit_rows', 1, '9', 'The number of rows in the edit post form (min 3, max 100)', 8, 5)",
    220220
    221221        // original options from options page
    222         "48" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (48,'posts_per_page', 1, '20','How many posts/days to show on the index page.', 4, 20)",
    223         "49" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (49,'what_to_show', 5, 'posts','Posts, days, or posts paged', 4, 20)",
    224         "50" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (50,'archive_mode', 5, 'monthly','Which \'unit\' to use for archives.', 4, 20)",
    225         "51" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (51,'time_difference', 6, '0', 'if you\'re not on the timezone of your server', 4, 20)",
    226         "52" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (52,'date_format', 3, 'n/j/Y', 'see note for format characters', 4, 20)",
    227         "53" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (53,'time_format', 3, 'g:i a', 'see note for format characters', 4, 20)",       "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (84,'use_geo_positions', 2, '0', 'Turns on the geo url features of WordPress', 8, 20)",
    228         "85" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (85,'use_default_geourl', 2, '1','enables placement of default GeoURL ICBM location even when no other specified', 8, 20)",
    229         "86" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (86,'default_geourl_lat ', 8, 0.0, 'The default Latitude ICBM value - <a href=\"http://www.geourl.org/resources.html\" target=\"_blank\">see here</a>', 8, 20)",
    230         "87" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (87,'default_geourl_lon', 8, 0.0, 'The default Longitude ICBM value', 8, 20)",
    231         "60" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (60,'links_minadminlevel',             1, '5', 'The minimum admin level to edit links', 8, 10)",
    232         "61" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (61,'links_use_adminlevels',           2, '1', 'set this to false to have all links visible and editable to everyone in the link manager', 8, 20)",
    233         "62" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (62,'links_rating_type',               5, 'image', 'Set this to the type of rating indication you wish to use', 8, 10)",
    234         "63" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (63,'links_rating_char',               3, '*', 'If we are set to \'char\' which char to use.', 8, 5)",
    235         "64" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (64,'links_rating_ignore_zero',        2, '1', 'What do we do with a value of zero? set this to true to output nothing, 0 to output as normal (number/image)', 8, 20)",
    236         "65" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (65,'links_rating_single_image',       2, '1', 'Use the same image for each rating point? (Uses links_rating_image[0])', 8, 20)",
    237         "66" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (66,'links_rating_image0',             3, 'wp-links/links-images/tick.png', 'Image for rating 0 (and for single image)', 8, 40)",
    238         "67" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (67,'links_rating_image1',             3, 'wp-links/links-images/rating-1.gif', 'Image for rating 1', 8, 40)",
    239         "68" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (68,'links_rating_image2',             3, 'wp-links/links-images/rating-2.gif', 'Image for rating 2', 8, 40)",
    240         "69" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (69,'links_rating_image3',             3, 'wp-links/links-images/rating-3.gif', 'Image for rating 3', 8, 40)",
    241         "70" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (70,'links_rating_image4',             3, 'wp-links/links-images/rating-4.gif', 'Image for rating 4', 8, 40)",
    242         "71" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (71,'links_rating_image5',             3, 'wp-links/links-images/rating-5.gif', 'Image for rating 5', 8, 40)",
    243         "72" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (72,'links_rating_image6',             3, 'wp-links/links-images/rating-6.gif', 'Image for rating 6', 8, 40)",
    244         "73" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (73,'links_rating_image7',             3, 'wp-links/links-images/rating-7.gif', 'Image for rating 7', 8, 40)",
    245         "74" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (74,'links_rating_image8',             3, 'wp-links/links-images/rating-8.gif', 'Image for rating 8', 8, 40)",
    246         "75" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (75,'links_rating_image9',             3, 'wp-links/links-images/rating-9.gif', 'Image for rating 9', 8, 40)",
    247         "77" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (77,'weblogs_xml_url',                 3, 'http://www.weblogs.com/changes.xml', 'Which file to grab from weblogs.com', 8, 40)",
    248         "78" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (78,'weblogs_cacheminutes',            1, '60', 'cache time in minutes (if it is older than this get a new copy)', 8, 10)",
    249         "79" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (79,'links_updated_date_format',       3, 'd/m/Y h:i', 'The date format for the updated tooltip', 8, 25)",
    250         "80" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (80,'links_recently_updated_prepend',  3, '&gt;&gt;', 'The text to prepend to a recently updated link', 8, 10)",
    251         "81" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (81,'links_recently_updated_append',   3, '&lt;&lt;', 'The text to append to a recently updated link', 8, 20)",
    252         "82" => "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (82,'links_recently_updated_time',     1, '120', 'The time in minutes to consider a link recently updated', 8, 20)"
     222        "48" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (48,'posts_per_page', 1, '20','How many posts/days to show on the index page.', 4, 20)",
     223        "49" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (49,'what_to_show', 5, 'posts','Posts, days, or posts paged', 4, 20)",
     224        "50" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (50,'archive_mode', 5, 'monthly','Which \'unit\' to use for archives.', 4, 20)",
     225        "51" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (51,'time_difference', 6, '0', 'if you\'re not on the timezone of your server', 4, 20)",
     226        "52" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (52,'date_format', 3, 'n/j/Y', 'see note for format characters', 4, 20)",
     227        "53" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (53,'time_format', 3, 'g:i a', 'see note for format characters', 4, 20)",      "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (84,'use_geo_positions', 2, '0', 'Turns on the geo url features of WordPress', 8, 20)",
     228        "85" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (85,'use_default_geourl', 2, '1','enables placement of default GeoURL ICBM location even when no other specified', 8, 20)",
     229        "86" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (86,'default_geourl_lat ', 8, 0.0, 'The default Latitude ICBM value - <a href=\"http://www.geourl.org/resources.html\" target=\"_blank\">see here</a>', 8, 20)",
     230        "87" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (87,'default_geourl_lon', 8, 0.0, 'The default Longitude ICBM value', 8, 20)",
     231        "60" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (60,'links_minadminlevel',             1, '5', 'The minimum admin level to edit links', 8, 10)",
     232        "61" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (61,'links_use_adminlevels',           2, '1', 'set this to false to have all links visible and editable to everyone in the link manager', 8, 20)",
     233        "62" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (62,'links_rating_type',               5, 'image', 'Set this to the type of rating indication you wish to use', 8, 10)",
     234        "63" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (63,'links_rating_char',               3, '*', 'If we are set to \'char\' which char to use.', 8, 5)",
     235        "64" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (64,'links_rating_ignore_zero',        2, '1', 'What do we do with a value of zero? set this to true to output nothing, 0 to output as normal (number/image)', 8, 20)",
     236        "65" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (65,'links_rating_single_image',       2, '1', 'Use the same image for each rating point? (Uses links_rating_image[0])', 8, 20)",
     237        "66" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (66,'links_rating_image0',             3, 'wp-links/links-images/tick.png', 'Image for rating 0 (and for single image)', 8, 40)",
     238        "67" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (67,'links_rating_image1',             3, 'wp-links/links-images/rating-1.gif', 'Image for rating 1', 8, 40)",
     239        "68" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (68,'links_rating_image2',             3, 'wp-links/links-images/rating-2.gif', 'Image for rating 2', 8, 40)",
     240        "69" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (69,'links_rating_image3',             3, 'wp-links/links-images/rating-3.gif', 'Image for rating 3', 8, 40)",
     241        "70" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (70,'links_rating_image4',             3, 'wp-links/links-images/rating-4.gif', 'Image for rating 4', 8, 40)",
     242        "71" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (71,'links_rating_image5',             3, 'wp-links/links-images/rating-5.gif', 'Image for rating 5', 8, 40)",
     243        "72" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (72,'links_rating_image6',             3, 'wp-links/links-images/rating-6.gif', 'Image for rating 6', 8, 40)",
     244        "73" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (73,'links_rating_image7',             3, 'wp-links/links-images/rating-7.gif', 'Image for rating 7', 8, 40)",
     245        "74" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (74,'links_rating_image8',             3, 'wp-links/links-images/rating-8.gif', 'Image for rating 8', 8, 40)",
     246        "75" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (75,'links_rating_image9',             3, 'wp-links/links-images/rating-9.gif', 'Image for rating 9', 8, 40)",
     247        "77" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (77,'weblogs_xml_url',                 3, 'http://www.weblogs.com/changes.xml', 'Which file to grab from weblogs.com', 8, 40)",
     248        "78" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (78,'weblogs_cacheminutes',            1, '60', 'cache time in minutes (if it is older than this get a new copy)', 8, 10)",
     249        "79" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (79,'links_updated_date_format',       3, 'd/m/Y h:i', 'The date format for the updated tooltip', 8, 25)",
     250        "80" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (80,'links_recently_updated_prepend',  3, '&gt;&gt;', 'The text to prepend to a recently updated link', 8, 10)",
     251        "81" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (81,'links_recently_updated_append',   3, '&lt;&lt;', 'The text to append to a recently updated link', 8, 20)",
     252        "82" => "INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES (82,'links_recently_updated_time',     1, '120', 'The time in minutes to consider a link recently updated', 8, 20)"
    253253        );
    254254
    255255    foreach ($option_data as $option_id => $query) {
    256         if(!$wpdb->get_var("SELECT * FROM $tableoptions WHERE option_id = '$option_id'")) {
     256        if(!$wpdb->get_var("SELECT * FROM $wpdb->options WHERE option_id = '$option_id'")) {
    257257            $wpdb->query($query);
    258258        }
     
    260260   
    261261    $option_groups = array(
    262     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (1, 'Other Options', 'Posts per page etc. Original options page')",
    263     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (2, 'General blog settings', 'Things you\'ll probably want to tweak')",
    264     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (3, 'RSS/RDF Feeds, Track/Ping-backs', 'Settings for RSS/RDF Feeds, Track/ping-backs')",
    265     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (4, 'File uploads', 'Settings for file uploads')",
    266     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (5, 'Blog-by-Email settings', 'Settings for blogging via email')",
    267     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (6, 'Base settings', 'Basic settings required to get your blog working')",
    268     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (7, 'Default post options', 'Default settings for new posts.')",
    269     "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES (8, 'Link Manager Settings', 'Various settings for the link manager.')",
    270     "INSERT INTO $tableoptiongroups (group_id, group_name, group_desc) VALUES (9, 'Geo Options', 'Settings which control the posting and display of Geo Options')");
     262    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (1, 'Other Options', 'Posts per page etc. Original options page')",
     263    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (2, 'General blog settings', 'Things you\'ll probably want to tweak')",
     264    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (3, 'RSS/RDF Feeds, Track/Ping-backs', 'Settings for RSS/RDF Feeds, Track/ping-backs')",
     265    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (4, 'File uploads', 'Settings for file uploads')",
     266    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (5, 'Blog-by-Email settings', 'Settings for blogging via email')",
     267    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (6, 'Base settings', 'Basic settings required to get your blog working')",
     268    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (7, 'Default post options', 'Default settings for new posts.')",
     269    "INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES (8, 'Link Manager Settings', 'Various settings for the link manager.')",
     270    "INSERT INTO $wpdb->optiongroups (group_id, group_name, group_desc) VALUES (9, 'Geo Options', 'Settings which control the posting and display of Geo Options')");
    271271
    272272    foreach ($option_groups as $query) {
    273273        $option_id = preg_match('|VALUES \(([0-9]+)|', $query, $matches);
    274274        $option_id = $matches[1];
    275         if(!$wpdb->get_var("SELECT * FROM $tableoptiongroups WHERE group_id = '$option_id'")) {
     275        if(!$wpdb->get_var("SELECT * FROM $wpdb->optiongroups WHERE group_id = '$option_id'")) {
    276276            $wpdb->query($query);
    277277            }
    278278    }   
    279279   
    280     $optiongroup_options = array (      "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,48,1 )",
    281         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,49,2 )",
    282         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,50,3 )",
    283         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,51,4 )",
    284         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,52,5 )",
    285         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (1,53,6 )",
    286        
    287        
    288         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,9 ,1 )",
    289         //"INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,10,2 )",
    290         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,11,3 )",
    291         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,12,4 )",
    292         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,13,5 )",
    293         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,14,6 )",
    294         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,15,7 )",
    295         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,16,8 )",
    296         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,17,9 )",
    297         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,18,10)",
    298         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,19,11)",
    299         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (2,20,12)",
    300        
    301        
    302         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,21,1 )",
    303         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,22,2 )",
    304         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,23,3 )",
    305         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,24,4 )",
    306         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,25,5 )",
    307         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,26,6 )",
    308         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,27,7 )",
    309         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,28,8 )",
    310         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,29,9 )",
    311         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (3,30,10)",
    312        
    313        
    314         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,31,1 )",
    315         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,32,2 )",
    316         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,33,3 )",
    317         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,34,4 )",
    318         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,35,5 )",
    319         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,36,6 )",
    320         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (4,37,7 )",
    321        
    322        
    323         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,38,1 )",
    324         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,39,2 )",
    325         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,40,3 )",
    326         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,41,4 )",
    327         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,42,5 )",
    328         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,43,6 )",
    329         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,44,7 )",
    330         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,45,8 )",
    331         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,46,9 )",
    332         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (5,47,10)",
    333        
    334        
    335         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,1,1)",
    336         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,2,2)",
    337         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,3,3)",
    338         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,4,4)",
    339         //"INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,6,5)",
    340         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,7,6)",
    341         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,8,7)",
    342         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (6,54,8)",
    343         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,55,1 )",
    344         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,56,2 )",
    345         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,57,3 )",
    346         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,58,4 )",
    347         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,59,5 )",
    348         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (7,83,5 )",
    349         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,60,1 )",
    350         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,61,2 )",
    351         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,62,3 )",
    352         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,63,4 )",
    353         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,64,5 )",
    354         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,65,6 )",
    355         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,66,7 )",
    356         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,67,8 )",
    357         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,68,9 )",
    358         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,69,10)",
    359         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,70,11)",
    360         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,71,12)",
    361         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,72,13)",
    362         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,73,14)",
    363         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,74,15)",
    364         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,75,16)",
    365         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,76,17)",
    366         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,77,18)",
    367         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,78,19)",
    368         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,79,20)",
    369         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,80,21)",
    370         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,81,22)",
    371         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (8,82,23)",
    372             "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (9,84,1)",
    373         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (9,85,1)",
    374         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (9,86,1)",
    375         "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES (9,87,1)",
     280    $optiongroup_options = array (      "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,48,1 )",
     281        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,49,2 )",
     282        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,50,3 )",
     283        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,51,4 )",
     284        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,52,5 )",
     285        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (1,53,6 )",
     286       
     287       
     288        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,9 ,1 )",
     289        //"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,10,2 )",
     290        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,11,3 )",
     291        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,12,4 )",
     292        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,13,5 )",
     293        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,14,6 )",
     294        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,15,7 )",
     295        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,16,8 )",
     296        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,17,9 )",
     297        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,18,10)",
     298        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,19,11)",
     299        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (2,20,12)",
     300       
     301       
     302        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,21,1 )",
     303        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,22,2 )",
     304        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,23,3 )",
     305        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,24,4 )",
     306        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,25,5 )",
     307        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,26,6 )",
     308        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,27,7 )",
     309        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,28,8 )",
     310        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,29,9 )",
     311        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (3,30,10)",
     312       
     313       
     314        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,31,1 )",
     315        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,32,2 )",
     316        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,33,3 )",
     317        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,34,4 )",
     318        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,35,5 )",
     319        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,36,6 )",
     320        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (4,37,7 )",
     321       
     322       
     323        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,38,1 )",
     324        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,39,2 )",
     325        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,40,3 )",
     326        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,41,4 )",
     327        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,42,5 )",
     328        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,43,6 )",
     329        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,44,7 )",
     330        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,45,8 )",
     331        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,46,9 )",
     332        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (5,47,10)",
     333       
     334       
     335        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,1,1)",
     336        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,2,2)",
     337        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,3,3)",
     338        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,4,4)",
     339        //"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,6,5)",
     340        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,7,6)",
     341        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,8,7)",
     342        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (6,54,8)",
     343        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,55,1 )",
     344        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,56,2 )",
     345        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,57,3 )",
     346        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,58,4 )",
     347        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,59,5 )",
     348        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (7,83,5 )",
     349        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,60,1 )",
     350        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,61,2 )",
     351        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,62,3 )",
     352        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,63,4 )",
     353        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,64,5 )",
     354        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,65,6 )",
     355        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,66,7 )",
     356        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,67,8 )",
     357        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,68,9 )",
     358        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,69,10)",
     359        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,70,11)",
     360        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,71,12)",
     361        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,72,13)",
     362        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,73,14)",
     363        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,74,15)",
     364        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,75,16)",
     365        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,76,17)",
     366        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,77,18)",
     367        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,78,19)",
     368        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,79,20)",
     369        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,80,21)",
     370        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,81,22)",
     371        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (8,82,23)",
     372            "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (9,84,1)",
     373        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (9,85,1)",
     374        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (9,86,1)",
     375        "INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES (9,87,1)",
    376376    );
    377377
     
    379379        preg_match('|VALUES \([0-9]+,([0-9]+)|', $query, $matches);
    380380        $option_id = $matches[1];
    381         if(!$wpdb->get_var("SELECT * FROM $tableoptiongroup_options WHERE option_id = '$option_id'")) {
     381        if(!$wpdb->get_var("SELECT * FROM $wpdb->optiongroup_options WHERE option_id = '$option_id'")) {
    382382            $wpdb->query($query);
    383383            }
     
    386386    $option_values = array(
    387387        // select data for what to show
    388         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days',  'days',        null,null,1)",
    389         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts',       null,null,2)",
    390         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
     388        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days',  'days',        null,null,1)",
     389        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts',       null,null,2)",
     390        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
    391391        // select data for archive mode
    392         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily',     'daily',       null,null,1)",
    393         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly',    'weekly',      null,null,2)",
    394         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly',   'monthly',     null,null,3)",
    395         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)",
     392        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily',     'daily',       null,null,1)",
     393        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly',    'weekly',      null,null,2)",
     394        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly',   'monthly',     null,null,3)",
     395        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)",
    396396        // select data for time diff
    397         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)",
     397        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)",
    398398        // select data for start of week
    399         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday',   null,null,1)",
    400         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday',   null,null,2)",
    401         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)",
     399        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday',   null,null,1)",
     400        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday',   null,null,2)",
     401        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)",
    402402       
    403403       
     
    408408        // default_ping_status select one of open closed
    409409        // default_pingback_flag select one of checked unchecked
    410         // default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $tablecategories order by cat_name"
     410        // default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name"
    411411       
    412412   
     
    414414       
    415415        // select data for post_status
    416         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)",
    417         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft',   'Draft',   null,null,2)",
    418         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)",
     416        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)",
     417        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft',   'Draft',   null,null,2)",
     418        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)",
    419419       
    420420        // select data for comment_status
    421         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open',   null,null,1)",
    422         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)",
     421        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open',   null,null,1)",
     422        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)",
    423423       
    424424        // select data for ping_status (aargh duplication!)
    425         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open',   null,null,1)",
    426         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)",
     425        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open',   null,null,1)",
     426        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)",
    427427       
    428428        // select data for pingback flag
    429         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked',   null,null,1)",
    430         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)",
     429        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked',   null,null,1)",
     430        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)",
    431431       
    432432        // sql select data for default
    433         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (59, 'SELECT cat_id AS value, cat_name AS label FROM $tablecategories order by cat_name', '', null,null,1)",
    434         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number',    null,null,1)",
    435         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char',   'Character', null,null,2)",
    436         "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image',  'Image',     null,null,3)"
     433        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (59, 'SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name', '', null,null,1)",
     434        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number',    null,null,1)",
     435        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char',   'Character', null,null,2)",
     436        "INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image',  'Image',     null,null,3)"
    437437        );
    438438       
     
    441441        $option_id = $matches[1];
    442442        $value = $matches[2];
    443         if(!$wpdb->get_var("SELECT * FROM $tableoptionvalues WHERE option_id = '$option_id' AND optionvalue = '$value'")) {
     443        if(!$wpdb->get_var("SELECT * FROM $wpdb->optionvalues WHERE option_id = '$option_id' AND optionvalue = '$value'")) {
    444444            $wpdb->query($query);
    445445            }
     
    451451   
    452452        // now update the database with those settings
    453         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_minadminlevel           )."' WHERE option_id=60"; $q = $wpdb->query($query);
    454         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_use_adminlevels         )."' WHERE option_id=61"; $q = $wpdb->query($query);
    455         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_type             )."' WHERE option_id=62"; $q = $wpdb->query($query);
    456         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_char             )."' WHERE option_id=63"; $q = $wpdb->query($query);
    457         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_ignore_zero      )."' WHERE option_id=64"; $q = $wpdb->query($query);
    458         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_single_image     )."' WHERE option_id=65"; $q = $wpdb->query($query);
    459         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image0           )."' WHERE option_id=66"; $q = $wpdb->query($query);
    460         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image1           )."' WHERE option_id=67"; $q = $wpdb->query($query);
    461         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image2           )."' WHERE option_id=68"; $q = $wpdb->query($query);
    462         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image3           )."' WHERE option_id=69"; $q = $wpdb->query($query);
    463         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image4           )."' WHERE option_id=70"; $q = $wpdb->query($query);
    464         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image5           )."' WHERE option_id=71"; $q = $wpdb->query($query);
    465         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image6           )."' WHERE option_id=72"; $q = $wpdb->query($query);
    466         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image7           )."' WHERE option_id=73"; $q = $wpdb->query($query);
    467         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image8           )."' WHERE option_id=74"; $q = $wpdb->query($query);
    468         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_rating_image9           )."' WHERE option_id=75"; $q = $wpdb->query($query);
    469         $query = "UPDATE $tableoptions SET option_value='".addslashes($weblogs_cache_file            )."' WHERE option_id=76"; $q = $wpdb->query($query);
    470         $query = "UPDATE $tableoptions SET option_value='".addslashes($weblogs_xml_url               )."' WHERE option_id=77"; $q = $wpdb->query($query);
    471         $query = "UPDATE $tableoptions SET option_value='".addslashes($weblogs_cacheminutes          )."' WHERE option_id=78"; $q = $wpdb->query($query);
    472         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_updated_date_format     )."' WHERE option_id=79"; $q = $wpdb->query($query);
    473         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_recently_updated_prepend)."' WHERE option_id=80"; $q = $wpdb->query($query);
    474         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_recently_updated_append )."' WHERE option_id=81"; $q = $wpdb->query($query);
    475         $query = "UPDATE $tableoptions SET option_value='".addslashes($links_recently_updated_time   )."' WHERE option_id=82"; $q = $wpdb->query($query);
     453        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_minadminlevel           )."' WHERE option_id=60"; $q = $wpdb->query($query);
     454        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_use_adminlevels         )."' WHERE option_id=61"; $q = $wpdb->query($query);
     455        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_type             )."' WHERE option_id=62"; $q = $wpdb->query($query);
     456        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_char             )."' WHERE option_id=63"; $q = $wpdb->query($query);
     457        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_ignore_zero      )."' WHERE option_id=64"; $q = $wpdb->query($query);
     458        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_single_image     )."' WHERE option_id=65"; $q = $wpdb->query($query);
     459        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image0           )."' WHERE option_id=66"; $q = $wpdb->query($query);
     460        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image1           )."' WHERE option_id=67"; $q = $wpdb->query($query);
     461        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image2           )."' WHERE option_id=68"; $q = $wpdb->query($query);
     462        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image3           )."' WHERE option_id=69"; $q = $wpdb->query($query);
     463        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image4           )."' WHERE option_id=70"; $q = $wpdb->query($query);
     464        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image5           )."' WHERE option_id=71"; $q = $wpdb->query($query);
     465        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image6           )."' WHERE option_id=72"; $q = $wpdb->query($query);
     466        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image7           )."' WHERE option_id=73"; $q = $wpdb->query($query);
     467        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image8           )."' WHERE option_id=74"; $q = $wpdb->query($query);
     468        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_rating_image9           )."' WHERE option_id=75"; $q = $wpdb->query($query);
     469        $query = "UPDATE $wpdb->options SET option_value='".addslashes($weblogs_cache_file            )."' WHERE option_id=76"; $q = $wpdb->query($query);
     470        $query = "UPDATE $wpdb->options SET option_value='".addslashes($weblogs_xml_url               )."' WHERE option_id=77"; $q = $wpdb->query($query);
     471        $query = "UPDATE $wpdb->options SET option_value='".addslashes($weblogs_cacheminutes          )."' WHERE option_id=78"; $q = $wpdb->query($query);
     472        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_updated_date_format     )."' WHERE option_id=79"; $q = $wpdb->query($query);
     473        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_recently_updated_prepend)."' WHERE option_id=80"; $q = $wpdb->query($query);
     474        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_recently_updated_append )."' WHERE option_id=81"; $q = $wpdb->query($query);
     475        $query = "UPDATE $wpdb->options SET option_value='".addslashes($links_recently_updated_time   )."' WHERE option_id=82"; $q = $wpdb->query($query);
    476476    // end if links.config.php exists
    477477    }
     
    480480
    481481function upgrade_100() {
    482     global $wpdb, $tableposts, $tablecomments, $tablecategories, $tableoptionvalues, $tableoptiongroups, $tableoptiongroup_options, $tableoptions, $tablepost2cat, $tablelinks, $tableusers;
    483     maybe_add_column($tableposts, 'post_name', "ALTER TABLE `$tableposts` ADD `post_name` VARCHAR(200) NOT NULL");
    484     maybe_add_column($tableposts, 'to_ping', "ALTER TABLE $tableposts ADD `to_ping` TEXT NOT NULL");
    485     maybe_add_column($tableposts, 'pinged', "ALTER TABLE $tableposts ADD `pinged` TEXT NOT NULL");
    486     maybe_add_column($tableposts, 'post_modified', "ALTER TABLE $tableposts ADD `post_modified` DATETIME NOT NULL");
    487     maybe_add_column($tableposts, 'post_content_filtered', "ALTER TABLE $tableposts ADD `post_content_filtered` TEXT NOT NULL");
    488     maybe_add_column($tablecategories, 'category_nicename', "ALTER TABLE `$tablecategories` ADD `category_nicename` VARCHAR(200) NOT NULL");   
    489     maybe_add_column($tablecategories, 'category_description', "ALTER TABLE `$tablecategories` ADD `category_description` TEXT NOT NULL");
    490     maybe_add_column($tablecategories, 'category_parent', "ALTER TABLE `$tablecategories` ADD `category_parent` INT(4) NOT NULL");
    491     maybe_add_column($tablelinks, 'link_rss', "ALTER TABLE `$tablelinks` ADD `link_rss` VARCHAR( 255 ) NOT NULL;");
    492     maybe_add_column($tableusers, 'user_description', "ALTER TABLE `$tableusers` ADD `user_description` TEXT NOT NULL");
    493     maybe_add_column($tablecomments, 'comment_approved', "ALTER TABLE $tablecomments ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL");
     482    global $wpdb;
     483    maybe_add_column($wpdb->posts, 'post_name', "ALTER TABLE `$wpdb->posts` ADD `post_name` VARCHAR(200) NOT NULL");
     484    maybe_add_column($wpdb->posts, 'to_ping', "ALTER TABLE $wpdb->posts ADD `to_ping` TEXT NOT NULL");
     485    maybe_add_column($wpdb->posts, 'pinged', "ALTER TABLE $wpdb->posts ADD `pinged` TEXT NOT NULL");
     486    maybe_add_column($wpdb->posts, 'post_modified', "ALTER TABLE $wpdb->posts ADD `post_modified` DATETIME NOT NULL");
     487    maybe_add_column($wpdb->posts, 'post_content_filtered', "ALTER TABLE $wpdb->posts ADD `post_content_filtered` TEXT NOT NULL");
     488    maybe_add_column($wpdb->categories, 'category_nicename', "ALTER TABLE `$wpdb->categories` ADD `category_nicename` VARCHAR(200) NOT NULL"); 
     489    maybe_add_column($wpdb->categories, 'category_description', "ALTER TABLE `$wpdb->categories` ADD `category_description` TEXT NOT NULL");
     490    maybe_add_column($wpdb->categories, 'category_parent', "ALTER TABLE `$wpdb->categories` ADD `category_parent` INT(4) NOT NULL");
     491    maybe_add_column($wpdb->links, 'link_rss', "ALTER TABLE `$wpdb->links` ADD `link_rss` VARCHAR( 255 ) NOT NULL;");
     492    maybe_add_column($wpdb->users, 'user_description', "ALTER TABLE `$wpdb->users` ADD `user_description` TEXT NOT NULL");
     493    maybe_add_column($wpdb->comments, 'comment_approved', "ALTER TABLE $wpdb->comments ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL");
    494494
    495495    // Create indicies
    496     add_clean_index($tableposts, 'post_name');
    497     add_clean_index($tablecategories, 'category_nicename');
    498     add_clean_index($tablecomments, 'comment_approved');
     496    add_clean_index($wpdb->posts, 'post_name');
     497    add_clean_index($wpdb->categories, 'category_nicename');
     498    add_clean_index($wpdb->comments, 'comment_approved');
    499499
    500500
    501501    // Options stuff
    502     if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'")) {
    503         $wpdb->query("INSERT INTO $tableoptions
     502    if (!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'comment_moderation'")) {
     503        $wpdb->query("INSERT INTO $wpdb->options
    504504            (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)
    505505            VALUES
     
    507507    }
    508508
    509     $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'");     
    510     $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'");
    511     $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'");
     509    $oid = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'comment_moderation'");     
     510    $gid = $wpdb->get_var("SELECT group_id FROM $wpdb->optiongroups WHERE group_name = 'General blog settings'");
     511    $seq = $wpdb->get_var("SELECT MAX(seq) FROM $wpdb->optiongroup_options WHERE group_id = '$gid'");
    512512    ++$seq;
    513     if (!$wpdb->get_row("SELECT * FROM $tableoptiongroup_options WHERE group_id = '$gid' AND option_id = '$oid'")) {
    514         $wpdb->query("INSERT INTO $tableoptiongroup_options
     513    if (!$wpdb->get_row("SELECT * FROM $wpdb->optiongroup_options WHERE group_id = '$gid' AND option_id = '$oid'")) {
     514        $wpdb->query("INSERT INTO $wpdb->optiongroup_options
    515515        (group_id, option_id, seq)
    516516        VALUES
     
    518518    }
    519519     
    520     if (!$wpdb->get_row("SELECT * FROM $tableoptionvalues WHERE option_id = $oid AND optionvalue = 'auto'")) {
    521         $wpdb->query("INSERT INTO $tableoptionvalues
     520    if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'auto'")) {
     521        $wpdb->query("INSERT INTO $wpdb->optionvalues
    522522        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
    523523        VALUES
    524524        ('$oid','auto', 'Automatic', NULL, NULL, 3)");
    525525    }
    526     if (!$wpdb->get_row("SELECT * FROM $tableoptionvalues WHERE option_id = $oid AND optionvalue = 'none'")) {
    527         $wpdb->query("INSERT INTO $tableoptionvalues
     526    if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'none'")) {
     527        $wpdb->query("INSERT INTO $wpdb->optionvalues
    528528        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
    529529        VALUES
    530530        ('$oid', 'none', 'None', NULL, NULL, 1)");
    531531    }
    532     if (!$wpdb->get_row("SELECT * FROM $tableoptionvalues WHERE option_id = $oid AND optionvalue = 'manual'")) {
    533         $wpdb->query("INSERT INTO $tableoptionvalues
     532    if (!$wpdb->get_row("SELECT * FROM $wpdb->optionvalues WHERE option_id = $oid AND optionvalue = 'manual'")) {
     533        $wpdb->query("INSERT INTO $wpdb->optionvalues
    534534        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
    535535        VALUES
     
    537537    }
    538538   
    539     if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'")) {
    540         $wpdb->query("INSERT INTO $tableoptions
     539    if (!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'moderation_notify'")) {
     540        $wpdb->query("INSERT INTO $wpdb->options
    541541            (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)
    542542            VALUES
     
    544544    }
    545545   
    546     $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'");       
    547     $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'");
     546    $oid = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'moderation_notify'");     
     547    $seq = $wpdb->get_var("SELECT MAX(seq) FROM $wpdb->optiongroup_options WHERE group_id = '$gid'");
    548548    ++$seq;
    549     if (!$wpdb->get_row("SELECT * FROM $tableoptiongroup_options WHERE group_id = '$gid' AND option_id = '$oid'")) {
    550         $wpdb->query("INSERT INTO $tableoptiongroup_options
     549    if (!$wpdb->get_row("SELECT * FROM $wpdb->optiongroup_options WHERE group_id = '$gid' AND option_id = '$oid'")) {
     550        $wpdb->query("INSERT INTO $wpdb->optiongroup_options
    551551            (group_id, option_id, seq)
    552552            VALUES
     
    554554    }
    555555    // Get the title and ID of every post, post_name to check if it already has a value
    556     $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $tableposts WHERE post_name = ''");
     556    $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
    557557    if ($posts) {
    558558        foreach($posts as $post) {
    559559            if ('' == $post->post_name) {
    560560                $newtitle = sanitize_title($post->post_title);
    561                 $wpdb->query("UPDATE $tableposts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
     561                $wpdb->query("UPDATE $wpdb->posts SET post_name = '$newtitle' WHERE ID = '$post->ID'");
    562562            }
    563563        }
    564564    }
    565565   
    566     $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $tablecategories");
     566    $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
    567567    foreach ($categories as $category) {
    568568        if ('' == $category->category_nicename) {
    569569            $newtitle = sanitize_title($category->cat_name);
    570             $wpdb->query("UPDATE $tablecategories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
    571         }
    572     }
    573    
    574     if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'permalink_structure'")) { // If it's not already there
    575         $wpdb->query("INSERT INTO `$tableoptions`
     570            $wpdb->query("UPDATE $wpdb->categories SET category_nicename = '$newtitle' WHERE cat_ID = '$category->cat_ID'");
     571        }
     572    }
     573   
     574    if (!$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = 'permalink_structure'")) { // If it's not already there
     575        $wpdb->query("INSERT INTO `$wpdb->options`
    576576            (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)
    577577            VALUES
     
    579579        }
    580580       
    581     if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'gzipcompression'")) { // If it's not already there
    582         $wpdb->query("INSERT INTO `$tableoptions`
     581    if (!$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = 'gzipcompression'")) { // If it's not already there
     582        $wpdb->query("INSERT INTO `$wpdb->options`
    583583            (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)
    584584            VALUES
    585585            ('', '0', 'gzipcompression', 'Y', '2', '0', '20', '8', 'Whether your output should be gzipped or not. Enable this if you don&#8217;t already have mod_gzip running.', '8');");
    586         $optionid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'gzipcompression'");
    587         $wpdb->query("INSERT INTO $tableoptiongroup_options
     586        $optionid = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'gzipcompression'");
     587        $wpdb->query("INSERT INTO $wpdb->optiongroup_options
    588588            (group_id, option_id, seq)
    589589            VALUES
    590590            (2, $optionid, 5)");
    591591        }
    592     if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'hack_file'")) {
    593         $wpdb->query("INSERT INTO `$tableoptions`
     592    if (!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'hack_file'")) {
     593        $wpdb->query("INSERT INTO `$wpdb->options`
    594594            ( `option_id` , `blog_id` , `option_name` , `option_can_override` , `option_type` , `option_value` , `option_width` , `option_height` , `option_description` , `option_admin_level` )
    595595            VALUES
    596596            ('', '0', 'hack_file', 'Y', '2', '0', '20', '8', 'Set this to true if you plan to use a hacks file. This is a place for you to store code hacks that won&#8217;t be overwritten when you upgrade. The file must be in your wordpress root and called <code>my-hacks.php</code>', '8')");
    597         $optionid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'hack_file'");
    598         $wpdb->query("INSERT INTO $tableoptiongroup_options
     597        $optionid = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'hack_file'");
     598        $wpdb->query("INSERT INTO $wpdb->optiongroup_options
    599599            (group_id, option_id, seq)
    600600            VALUES
     
    602602    }
    603603
    604     $wpdb->query("UPDATE $tableoptionvalues SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51");
     604    $wpdb->query("UPDATE $wpdb->optionvalues SET optionvalue_max = 23 , optionvalue_min = -23 WHERE option_id = 51");
    605605    // fix upload users description
    606     $wpdb->query("UPDATE $tableoptions SET option_description = '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'' WHERE option_id = 37");
     606    $wpdb->query("UPDATE $wpdb->options SET option_description = '...or you may authorize only some users. enter their logins here, separated by spaces. if you leave this variable blank, all users who have the minimum level are authorized to upload. example: \'barbara anne george\'' WHERE option_id = 37");
    607607    // and file types
    608     $wpdb->query("UPDATE $tableoptions SET option_description = 'accepted file types, separated by spaces. example: \'jpg gif png\'' WHERE option_id = 34");
     608    $wpdb->query("UPDATE $wpdb->options SET option_description = 'accepted file types, separated by spaces. example: \'jpg gif png\'' WHERE option_id = 34");
    609609    // add link to php date format. this could be to a wordpress.org page in the future
    610     $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 52");
    611     $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 53");
    612     $wpdb->query("UPDATE $tableoptions SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
     610    $wpdb->query("UPDATE $wpdb->options SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 52");
     611    $wpdb->query("UPDATE $wpdb->options SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 53");
     612    $wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
    613613                                                      WHERE option_name LIKE 'links_rating_image%'
    614614                                                      AND option_value LIKE 'wp-links/links-images/%'");
    615     $wpdb->query("DELETE FROM $tableoptions WHERE option_name = 'comment_allowed_tags'");
    616     $wpdb->query("DELETE FROM $tableoptions WHERE option_name = 'use_preview'");
    617     $wpdb->query("DELETE FROM $tableoptions WHERE option_name = 'search_engine_friendly_urls'");
     615    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'comment_allowed_tags'");
     616    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'use_preview'");
     617    $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = 'search_engine_friendly_urls'");
    618618    // Multiple categories
    619     maybe_create_table($tablepost2cat, "
    620         CREATE TABLE `$tablepost2cat` (
     619    maybe_create_table($wpdb->post2cat, "
     620        CREATE TABLE `$wpdb->post2cat` (
    621621        `rel_id` INT NOT NULL AUTO_INCREMENT ,
    622622        `post_id` INT NOT NULL ,
     
    627627        ");
    628628
    629     $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $tablepost2cat");
     629    $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
    630630    if ($done_ids) :
    631631        foreach ($done_ids as $done_id) :
     
    637637    endif;
    638638   
    639     $allposts = $wpdb->get_results("SELECT ID, post_category FROM $tableposts WHERE post_category != '0' $catwhere");
     639    $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
    640640    if ($allposts) :
    641641        foreach ($allposts as $post) {
    642642            // Check to see if it's already been imported
    643             $cat = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
     643            $cat = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post->ID AND category_id = $post->post_category");
    644644            if (!$cat && 0 != $post->post_category) { // If there's no result
    645645                $wpdb->query("
    646                     INSERT INTO $tablepost2cat
     646                    INSERT INTO $wpdb->post2cat
    647647                    (post_id, category_id)
    648648                    VALUES
     
    655655
    656656function upgrade_101() {
    657     global $wpdb, $tableoptionvalues, $tablelinkcategories, $tableposts, $tablecategories, $tablecomments, $tablelinks;
     657    global $wpdb;
    658658    // Fix possible duplicate problem from CVS, we can REMOVE this later
    659     $option59 = $wpdb->get_results("SELECT * FROM $tableoptionvalues WHERE option_id  = '59'");
     659    $option59 = $wpdb->get_results("SELECT * FROM $wpdb->optionvalues WHERE option_id  = '59'");
    660660    if (1 < count($option59)) {
    661         $wpdb->query("DELETE FROM $tableoptionvalues WHERE option_id = '59' AND optionvalue LIKE('%FROM  order%')");
     661        $wpdb->query("DELETE FROM $wpdb->optionvalues WHERE option_id = '59' AND optionvalue LIKE('%FROM  order%')");
    662662    }
    663663   
    664664    // Remove 'automatic' option for comment moderation until it actually does something
    665     $wpdb->query("DELETE FROM $tableoptionvalues WHERE optionvalue = 'auto'");
     665    $wpdb->query("DELETE FROM $wpdb->optionvalues WHERE optionvalue = 'auto'");
    666666    // Less intrusive default
    667     $wpdb->query("ALTER TABLE `$tablelinkcategories` CHANGE `show_description` `show_description` ENUM( 'Y', 'N' ) DEFAULT 'N' NOT NULL");
     667    $wpdb->query("ALTER TABLE `$wpdb->linkcategories` CHANGE `show_description` `show_description` ENUM( 'Y', 'N' ) DEFAULT 'N' NOT NULL");
    668668   
    669669    // Clean up indices, add a few
    670     add_clean_index($tableposts, 'post_name');
    671     add_clean_index($tableposts, 'post_status');
    672     add_clean_index($tablecategories, 'category_nicename');
    673     add_clean_index($tablecomments, 'comment_approved');
    674     add_clean_index($tablecomments, 'comment_post_ID');
    675     add_clean_index($tablelinks , 'link_category');
    676     add_clean_index($tablelinks , 'link_visible');
     670    add_clean_index($wpdb->posts, 'post_name');
     671    add_clean_index($wpdb->posts, 'post_status');
     672    add_clean_index($wpdb->categories, 'category_nicename');
     673    add_clean_index($wpdb->comments, 'comment_approved');
     674    add_clean_index($wpdb->comments, 'comment_post_ID');
     675    add_clean_index($wpdb->links , 'link_category');
     676    add_clean_index($wpdb->links , 'link_visible');
    677677}
    678678
    679679
    680680function upgrade_110() {
    681   global $wpdb, $tableusers, $tablecomments, $tableposts, $tableoptiongroups, $tableoptiongroup_options, $tableoptions, $tablepostmeta;
    682    
    683     maybe_add_column($tablecomments, 'user_id', "ALTER TABLE `$tablecomments` ADD `user_id` INT DEFAULT '0' NOT NULL ;");
    684     maybe_add_column($tableusers, 'user_activation_key', "ALTER TABLE `$tableusers` ADD `user_activation_key` VARCHAR( 60 ) NOT NULL ;");
    685     maybe_add_column($tableusers, 'user_status', "ALTER TABLE `$tableusers` ADD `user_status` INT DEFAULT '0' NOT NULL ;");
    686     $wpdb->query("ALTER TABLE `$tableposts` CHANGE `comment_status` `comment_status` ENUM( 'open', 'closed', 'registered_only' ) DEFAULT 'open' NOT NULL");
    687 
    688     maybe_add_column($tableusers, 'user_nicename', "ALTER TABLE `$tableusers` ADD `user_nicename` VARCHAR(50) DEFAULT '' NOT NULL ;");
    689     maybe_add_column($tableposts, 'post_date_gmt', "ALTER TABLE $tableposts ADD post_date_gmt DATETIME NOT NULL AFTER post_date");
    690     maybe_add_column($tableposts, 'post_modified_gmt', "ALTER TABLE $tableposts ADD post_modified_gmt DATETIME NOT NULL AFTER post_modified");
    691     maybe_add_column($tablecomments, 'comment_date_gmt', "ALTER TABLE $tablecomments ADD comment_date_gmt DATETIME NOT NULL AFTER comment_date");
     681  global $wpdb;
     682   
     683    maybe_add_column($wpdb->comments, 'user_id', "ALTER TABLE `$wpdb->comments` ADD `user_id` INT DEFAULT '0' NOT NULL ;");
     684    maybe_add_column($wpdb->users, 'user_activation_key', "ALTER TABLE `$wpdb->users` ADD `user_activation_key` VARCHAR( 60 ) NOT NULL ;");
     685    maybe_add_column($wpdb->users, 'user_status', "ALTER TABLE `$wpdb->users` ADD `user_status` INT DEFAULT '0' NOT NULL ;");
     686    $wpdb->query("ALTER TABLE `$wpdb->posts` CHANGE `comment_status` `comment_status` ENUM( 'open', 'closed', 'registered_only' ) DEFAULT 'open' NOT NULL");
     687
     688    maybe_add_column($wpdb->users, 'user_nicename', "ALTER TABLE `$wpdb->users` ADD `user_nicename` VARCHAR(50) DEFAULT '' NOT NULL ;");
     689    maybe_add_column($wpdb->posts, 'post_date_gmt', "ALTER TABLE $wpdb->posts ADD post_date_gmt DATETIME NOT NULL AFTER post_date");
     690    maybe_add_column($wpdb->posts, 'post_modified_gmt', "ALTER TABLE $wpdb->posts ADD post_modified_gmt DATETIME NOT NULL AFTER post_modified");
     691    maybe_add_column($wpdb->comments, 'comment_date_gmt', "ALTER TABLE $wpdb->comments ADD comment_date_gmt DATETIME NOT NULL AFTER comment_date");
    692692
    693693    // Set user_nicename.
    694     $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $tableusers");
     694    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
    695695    foreach ($users as $user) {
    696696        if ('' == $user->user_nicename) {
    697697            $newname = sanitize_title($user->user_nickname);
    698             $wpdb->query("UPDATE $tableusers SET user_nicename = '$newname' WHERE ID = '$user->ID'");
     698            $wpdb->query("UPDATE $wpdb->users SET user_nicename = '$newname' WHERE ID = '$user->ID'");
    699699        }
    700700    }
    701701
    702702    // Convert passwords to MD5 and update table appropiately
    703     $query = 'DESCRIBE '.$tableusers.' user_pass';
     703    $query = 'DESCRIBE '.$wpdb->users.' user_pass';
    704704    $res = $wpdb->get_results($query);
    705705    if ($res[0]['Type'] != 'varchar(32)') {
    706         $wpdb->query('ALTER TABLE '.$tableusers.' MODIFY user_pass varchar(64) not null');
    707     }
    708    
    709     $query = 'SELECT ID, user_pass from '.$tableusers;
     706        $wpdb->query('ALTER TABLE '.$wpdb->users.' MODIFY user_pass varchar(64) not null');
     707    }
     708   
     709    $query = 'SELECT ID, user_pass from '.$wpdb->users;
    710710    foreach ($wpdb->get_results($query) as $row) {
    711711        if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
    712                $wpdb->query('UPDATE '.$tableusers.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
    713         }
    714     }
    715    
    716     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 1");
    717     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 2");
    718     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 3");
    719     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 4");
    720     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 5");
    721     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 6");
    722     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 7");
    723     $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 9");
    724 
    725     $wpdb->query("UPDATE $tableoptiongroups SET group_name = 'Link Manager' WHERE group_id = 8");
    726     $wpdb->query("UPDATE $tableoptiongroups SET group_name = 'Geo-data' WHERE group_id = 9");
     712               $wpdb->query('UPDATE '.$wpdb->users.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
     713        }
     714    }
     715   
     716    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 1");
     717    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 2");
     718    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 3");
     719    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 4");
     720    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 5");
     721    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 6");
     722    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 7");
     723    $wpdb->query("DELETE FROM $wpdb->optiongroups WHERE group_id = 9");
     724
     725    $wpdb->query("UPDATE $wpdb->optiongroups SET group_name = 'Link Manager' WHERE group_id = 8");
    727726
    728727    // Add blog_charset option
    729     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'blog_charset'")) {
    730         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('blog_charset', 3, 'utf-8', 8)");
     728    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'blog_charset'")) {
     729        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('blog_charset', 3, 'utf-8', 8)");
    731730    }
    732731
     
    746745    // Add a gmt_offset option, with value $gmt_offset
    747746    if (!get_settings('gmt_offset')) {
    748         if(!$wpdb->get_var("SELECT * FROM $tableoptions WHERE option_name = 'gmt_offset'")) {
    749             $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_description, option_admin_level) VALUES ('gmt_offset', 8, $gmt_offset, 'The difference in hours between GMT and your timezone', 8)");
     747        if(!$wpdb->get_var("SELECT * FROM $wpdb->options WHERE option_name = 'gmt_offset'")) {
     748            $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_description, option_admin_level) VALUES ('gmt_offset', 8, $gmt_offset, 'The difference in hours between GMT and your timezone', 8)");
    750749        }
    751750
     
    755754    // MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
    756755    // <michel_v> I just slapped myself silly for not thinking about it earlier
    757     $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $tableposts") == '0000-00-00 00:00:00') ? false : true;
     756    $got_gmt_fields = ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00') ? false : true;
    758757
    759758    if (!$got_gmt_fields) {
     
    762761        $add_hours = intval($diff_gmt_weblogger);
    763762        $add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
    764         $wpdb->query("UPDATE $tableposts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
    765         $wpdb->query("UPDATE $tableposts SET post_modified = post_date");
    766         $wpdb->query("UPDATE $tableposts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
    767         $wpdb->query("UPDATE $tablecomments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
    768         $wpdb->query("UPDATE $tableusers SET dateYMDhour = DATE_ADD(dateYMDhour, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
     763        $wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
     764        $wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
     765        $wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
     766        $wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
     767        $wpdb->query("UPDATE $wpdb->users SET dateYMDhour = DATE_ADD(dateYMDhour, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
    769768    }
    770769
    771770    // post-meta
    772     maybe_create_table($tablepostmeta, "
    773     CREATE TABLE $tablepostmeta (
     771    maybe_create_table($wpdb->postmeta, "
     772    CREATE TABLE $wpdb->postmeta (
    774773      meta_id int(11) NOT NULL auto_increment,
    775774      post_id int(11) NOT NULL default 0,
     
    783782
    784783    // First we need to enlarge option_value so it can hold larger values:
    785     $wpdb->query("ALTER TABLE `$tableoptions` CHANGE `option_value` `option_value` TEXT NOT NULL");
     784    $wpdb->query("ALTER TABLE `$wpdb->options` CHANGE `option_value` `option_value` TEXT NOT NULL");
    786785   
    787786    // Now an option for blog pinging
    788     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'ping_sites'")) {
    789         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('ping_sites', 3, 'http://rpc.pingomatic.com/', 8)");
     787    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'ping_sites'")) {
     788        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('ping_sites', 3, 'http://rpc.pingomatic.com/', 8)");
    790789    }
    791790   
    792791    // Option for using the advanced edit screen by default
    793     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'advanced_edit'")) {
    794         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('advanced_edit', 5, '0', 8)");
     792    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'advanced_edit'")) {
     793        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('advanced_edit', 5, '0', 8)");
    795794    }
    796795    // Fix for CVS versions
    797     $wpdb->query("UPDATE $tableoptions SET option_type = '5' WHERE option_name = 'advanced_edit'");
     796    $wpdb->query("UPDATE $wpdb->options SET option_type = '5' WHERE option_name = 'advanced_edit'");
    798797   
    799798    // Now an option for moderation words
    800     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_keys'")) {
    801         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('moderation_keys', 3, '', 8)");
     799    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'moderation_keys'")) {
     800        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('moderation_keys', 3, '', 8)");
    802801    }
    803802
    804803    // Option for plugins
    805     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'active_plugins'")) {
    806         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('active_plugins', 3, '', 8)");
     804    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'active_plugins'")) {
     805        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('active_plugins', 3, '', 8)");
    807806    }
    808807
    809808    // Option for max # of links per comment
    810     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_max_links'")) {
    811         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('comment_max_links', 3, '5', 8)");
     809    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'comment_max_links'")) {
     810        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('comment_max_links', 3, '5', 8)");
    812811    }
    813812
    814813    // Option for different blog URL
    815     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'home'")) {
    816         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('home', 3, '', 8)");
     814    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'home'")) {
     815        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('home', 3, '', 8)");
    817816    }
    818817
    819818    // Option for category base
    820     if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'category_base'")) {
    821         $wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '', 8)");
     819    if(!$wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = 'category_base'")) {
     820        $wpdb->query("INSERT INTO $wpdb->options (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '', 8)");
    822821    }
    823822
     
    829828
    830829    // Forward-thinking
    831     $wpdb->query("ALTER TABLE `$tableposts` CHANGE `post_status` `post_status` ENUM( 'publish', 'draft', 'private', 'static' ) DEFAULT 'publish' NOT NULL");
    832     maybe_add_column($tableposts, 'post_parent', "ALTER TABLE `$tableposts` ADD `post_parent` INT NOT NULL ;");
    833 
    834 
    835     $wpdb->query("ALTER TABLE `$tablecomments` CHANGE `comment_author_url` `comment_author_url` VARCHAR( 200 ) NOT NULL");
     830    $wpdb->query("ALTER TABLE `$wpdb->posts` CHANGE `post_status` `post_status` ENUM( 'publish', 'draft', 'private', 'static' ) DEFAULT 'publish' NOT NULL");
     831    maybe_add_column($wpdb->posts, 'post_parent', "ALTER TABLE `$wpdb->posts` ADD `post_parent` INT NOT NULL ;");
     832
     833
     834    $wpdb->query("ALTER TABLE `$wpdb->comments` CHANGE `comment_author_url` `comment_author_url` VARCHAR( 200 ) NOT NULL");
    836835}
    837836
Note: See TracChangeset for help on using the changeset viewer.