Make WordPress Core

Changeset 1355


Ignore:
Timestamp:
05/24/2004 08:22:18 AM (22 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.

Location:
trunk
Files:
52 edited

Legend:

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

    r1340 r1355  
    2020
    2121function get_nested_categories($default = 0) {
    22  global $post_ID, $tablecategories, $tablepost2cat, $mode, $wpdb;
     22 global $post_ID, $mode, $wpdb;
    2323
    2424 if ($post_ID) {
    2525   $checked_categories = $wpdb->get_col("
    2626     SELECT category_id
    27      FROM  $tablecategories, $tablepost2cat
    28      WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = '$post_ID'
     27     FROM  $wpdb->categories, $wpdb->post2cat
     28     WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = '$post_ID'
    2929     ");
    3030 } else {
    … …  
    3232 }
    3333
    34  $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY category_parent DESC, cat_name ASC");
     34 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY category_parent DESC, cat_name ASC");
    3535 $result = array();
    3636 foreach($categories as $category) {
    … …  
    6767// Dandy new recursive multiple category stuff.
    6868function cat_rows($parent = 0, $level = 0, $categories = 0) {
    69         global $wpdb, $tablecategories, $tablepost2cat, $bgcolor;
     69        global $wpdb, $bgcolor;
    7070        if (!$categories) {
    71                 $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
     71                $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    7272        }
    7373        if ($categories) {
    7474                foreach ($categories as $category) {
    7575                        if ($category->category_parent == $parent) {
    76                                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
     76                                $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    7777                                $pad = str_repeat('— ', $level);
    7878
    … …  
    9292
    9393function wp_dropdown_cats($currentcat, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
    94         global $wpdb, $tablecategories, $tablepost2cat, $bgcolor;
     94        global $wpdb, $bgcolor;
    9595        if (!$categories) {
    96                 $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
     96                $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    9797        }
    9898        if ($categories) {
    9999                foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    100                         $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
     100                        $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    101101                        $pad = str_repeat('– ', $level);
    102102                        echo "\n\t<option value='$category->cat_ID'";
    … …  
    200200// Some postmeta stuff
    201201function has_meta($postid) {
    202         global $wpdb, $tablepostmeta;
     202        global $wpdb;
    203203
    204204        return $wpdb->get_results("
    205205                SELECT meta_key, meta_value, meta_id, post_id
    206                 FROM $tablepostmeta
     206                FROM $wpdb->postmeta
    207207                WHERE post_id = '$postid'
    208208                ORDER BY meta_key,meta_id",ARRAY_A);
    … …  
    241241// Get a list of previously defined keys
    242242function get_meta_keys() {
    243         global $wpdb, $tablepostmeta;
     243        global $wpdb;
    244244       
    245245        $keys = $wpdb->get_col("
    246246                SELECT meta_key
    247                 FROM $tablepostmeta
     247                FROM $wpdb->postmeta
    248248                GROUP BY meta_key
    249249                ORDER BY meta_key");
    … …  
    253253
    254254function meta_form() {
    255         global $wpdb, $tablepostmeta;
     255        global $wpdb;
    256256        $keys = $wpdb->get_col("
    257257                SELECT meta_key
    258                 FROM $tablepostmeta
     258                FROM $wpdb->postmeta
    259259                GROUP BY meta_key
    260260                ORDER BY meta_id DESC
    … …  
    290290
    291291function add_meta($post_ID) {
    292         global $wpdb, $tablepostmeta;
     292        global $wpdb;
    293293       
    294294        $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ) );
    … …  
    307307
    308308                $result = $wpdb->query("
    309                                 INSERT INTO $tablepostmeta
     309                                INSERT INTO $wpdb->postmeta
    310310                                (post_id,meta_key,meta_value)
    311311                                VALUES ('$post_ID','$metakey','$metavalue')
    … …  
    315315
    316316function delete_meta($mid) {
    317         global $wpdb, $tablepostmeta;
    318 
    319         $result = $wpdb->query("DELETE FROM $tablepostmeta WHERE meta_id = '$mid'");
     317        global $wpdb;
     318
     319        $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
    320320}
    321321
    322322function update_meta($mid, $mkey, $mvalue) {
    323         global $wpdb, $tablepostmeta;
    324 
    325         return $wpdb->query("UPDATE $tablepostmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
     323        global $wpdb;
     324
     325        return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
    326326}
    327327
  • trunk/wp-admin/admin-header.php

    r1340 r1355  
    1515timer_start();
    1616
    17 $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
     17$dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE 1=1");
    1818foreach ($dogs as $catt) {
    1919    $cache_categories[$catt->cat_ID] = $catt;
  • trunk/wp-admin/auth.php

    r1317 r1355  
    66function veriflog() {
    77        global $cookiehash;
    8         global $tableusers, $wpdb;
     8        global $wpdb;
    99
    1010        if (!empty($_COOKIE['wordpressuser_' . $cookiehash])) {
    … …  
    2020                return false;
    2121
    22         $login = $wpdb->get_row("SELECT user_login, user_pass FROM $tableusers WHERE user_login = '$user_login'");
     22        $login = $wpdb->get_row("SELECT user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login'");
    2323
    2424        if (!$login) {
  • trunk/wp-admin/categories.php

    r1352 r1355  
    5252    $cat = intval($_POST['cat']);
    5353
    54     $wpdb->query("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')");
     54    $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')");
    5555   
    5656    header('Location: categories.php?message=1#addcat');
    … …  
    6868    $cat_name = get_catname($cat_ID);
    6969    $cat_name = addslashes($cat_name);
    70     $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = '$cat_ID'");
     70    $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    7171    $cat_parent = $category->category_parent;
    7272
    … …  
    7777        die (__('Cheatin&#8217; uh?'));
    7878
    79     $wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = '$cat_ID'");
    80     $wpdb->query("UPDATE $tablecategories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'");
    81     $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'");
     79    $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
     80    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$cat_parent' WHERE category_parent = '$cat_ID'");
     81    $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
    8282
    8383    header('Location: categories.php?message=2');
    … …  
    8989    require_once ('admin-header.php');
    9090    $cat_ID = intval($_GET['cat_ID']);
    91     $category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = '$cat_ID'");
     91    $category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    9292    $cat_name = stripslashes($category->cat_name);
    9393    ?>
    … …  
    130130    $category_description = $wpdb->escape(stripslashes($_POST['category_description']));
    131131
    132     $wpdb->query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'");
     132    $wpdb->query("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'");
    133133   
    134134    header('Location: categories.php?message=3');
  • trunk/wp-admin/edit-comments.php

    r1271 r1355  
    4646        foreach ($delete_comments as $comment) { // Check the permissions on each
    4747                $comment = intval($comment);
    48                 $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $tablecomments WHERE comment_ID = $comment");
    49                 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $post_id"));
     48                $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
     49                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id"));
    5050                if (($user_level > $authordata->user_level) or ($user_login == $authordata->user_login)) {
    51                         $wpdb->query("DELETE FROM $tablecomments WHERE comment_ID = $comment");
     51                        $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment");
    5252                        ++$i;
    5353                }
    … …  
    5858if (isset($_GET['s'])) {
    5959        $s = $wpdb->escape($_GET['s']);
    60         $comments = $wpdb->get_results("SELECT * FROM $tablecomments  WHERE
     60        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments  WHERE
    6161                comment_author LIKE '%$s%' OR
    6262                comment_author_email LIKE '%$s%' OR
    … …  
    6666                ORDER BY comment_date DESC");
    6767} else {
    68         $comments = $wpdb->get_results("SELECT * FROM $tablecomments ORDER BY comment_date DESC LIMIT 20");
     68        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments ORDER BY comment_date DESC LIMIT 20");
    6969}
    7070if ('view' == $mode) {
    … …  
    7272                echo '<ol>';
    7373                foreach ($comments as $comment) {
    74                 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID"));
     74                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
    7575                        $comment_status = wp_get_comment_status($comment->comment_ID);
    7676                        if ('unapproved' == $comment_status) {
    … …  
    9090                        } // end if any comments to show
    9191                        // Get post title
    92                         $post_title = $wpdb->get_var("SELECT post_title FROM $tableposts WHERE ID = $comment->comment_post_ID");
     92                        $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID");
    9393                        $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    9494                        ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a> | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
    … …  
    120120  </tr>';
    121121                foreach ($comments as $comment) {
    122                 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $tableposts WHERE ID = $comment->comment_post_ID"));
     122                $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
    123123                $bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';
    124124?>
  • trunk/wp-admin/edit.php

    r1271 r1355  
    1313<?php
    1414get_currentuserinfo();
    15 $drafts = $wpdb->get_results("SELECT ID, post_title FROM $tableposts WHERE post_status = 'draft' AND post_author = $user_ID");
     15$drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
    1616if ($drafts) {
    1717        ?>
    … …  
    4848    <select name='m'>
    4949        <?php
    50                 $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $tableposts ORDER BY post_date DESC");
     50                $arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts ORDER BY post_date DESC");
    5151                foreach ($arc_result as $arc_row) {                     
    5252                        $arc_year  = $arc_row->yyear;
    … …  
    126126if ( 1 == count($posts) ) {
    127127
    128         $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date");
     128        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id ORDER BY comment_date");
    129129        if ($comments) {
    130130        ?>
  • trunk/wp-admin/import-b2.php

    r1117 r1355  
    8383
    8484while ($row = mysql_fetch_row($result)) {
    85     if ($row[0] == $tablelinks)
     85    if ($row[0] == $wpdb->links)
    8686        $got_links = true;
    87     if ($row[0] == $tablelinkcategories)
     87    if ($row[0] == $wpdb->linkcategories)
    8888        $got_cats = true;
    8989    //print "Table: $row[0]<br />\n";
    9090}
    9191if (!$got_cats) {
    92     echo "<p>Can't find table '$tablelinkcategories', gonna create it...</p>\n";
    93     $sql = "CREATE TABLE $tablelinkcategories ( " .
     92    echo "<p>Can't find table '$wpdb->linkcategories', gonna create it...</p>\n";
     93    $sql = "CREATE TABLE $wpdb->linkcategories ( " .
    9494           " cat_id int(11) NOT NULL auto_increment, " .
    9595           " cat_name tinytext NOT NULL, ".
    … …  
    9797           " PRIMARY KEY (cat_id) ".
    9898           ") ";
    99     $result = mysql_query($sql) or print ("Can't create the table '$tablelinkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
     99    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->linkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
    100100    if ($result != false) {
    101         echo "<p>Table '$tablelinkcategories' created OK</p>\n";
     101        echo "<p>Table '$wpdb->linkcategories' created OK</p>\n";
    102102        $got_cats = true;
    103103    }
    104104} else {
    105     echo "<p>Found table '$tablelinkcategories', don't need to create it...</p>\n";
     105    echo "<p>Found table '$wpdb->linkcategories', don't need to create it...</p>\n";
    106106        $got_cats = true;
    107107}
    108108if (!$got_links) {
    109     echo "<p>Can't find '$tablelinks', gonna create it...</p>\n";
    110     $sql = "CREATE TABLE $tablelinks ( " .
     109    echo "<p>Can't find '$wpdb->links', gonna create it...</p>\n";
     110    $sql = "CREATE TABLE $wpdb->links ( " .
    111111           " link_id int(11) NOT NULL auto_increment,           " .
    112112           " link_url varchar(255) NOT NULL default '',         " .
    … …  
    124124           " PRIMARY KEY (link_id)                              " .
    125125           ") ";
    126     $result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database.<br />" . $sql . "<br />" . mysql_error());
    127         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
    128         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
    129         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://zed1.com/b2/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
     126    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->links' in the database.<br />" . $sql . "<br />" . mysql_error());
     127        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
     128        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
     129        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://zed1.com/b2/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '');");
    130130
    131131    if ($result != false) {
    132         echo "<p>Table '$tablelinks' created OK</p>\n";
     132        echo "<p>Table '$wpdb->links' created OK</p>\n";
    133133        $got_links = true;
    134134    }
    135135} else {
    136     echo "<p>Found table '$tablelinks', don't need to create it...</p>\n";
     136    echo "<p>Found table '$wpdb->links', don't need to create it...</p>\n";
    137137    echo "<p>... may need to update it though. Looking for column link_updated...</p>\n";
    138     $query = "SELECT link_updated FROM $tablelinks LIMIT 1";
     138    $query = "SELECT link_updated FROM $wpdb->links LIMIT 1";
    139139    $q = @mysql_query($query);
    140140    if ($q != false) {
    … …  
    143143        }
    144144    } else {
    145         $query = "ALTER TABLE $tablelinks ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
     145        $query = "ALTER TABLE $wpdb->links ADD COLUMN link_updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'";
    146146        $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
    147147        echo "<p>Added column link_updated...</p>\n";
    148148    }
    149149    echo "<p>Looking for column link_rel...</p>\n";
    150     $query = "SELECT link_rel FROM $tablelinks LIMIT 1";
     150    $query = "SELECT link_rel FROM $wpdb->links LIMIT 1";
    151151    $q = @mysql_query($query);
    152152    if ($q != false) {
    … …  
    155155        }
    156156    } else {
    157         $query = "ALTER TABLE $tablelinks ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' ";
     157        $query = "ALTER TABLE $wpdb->links ADD COLUMN link_rel varchar(255) NOT NULL DEFAULT '' ";
    158158        $q = mysql_query($query) or mysql_doh("Doh, couldn't add column.", $query, mysql_error());
    159159        echo "<p>Added column link_rel...</p>\n";
    … …  
    164164if ($got_links && $got_cats) {
    165165    echo "<p>Looking for category 1...</p>\n";
    166     $sql = "SELECT * FROM $tablelinkcategories WHERE cat_id=1 ";
    167     $result = mysql_query($sql) or print ("Can't query '$tablelinkcategories'.<br />" . $sql . "<br />" . mysql_error());
     166    $sql = "SELECT * FROM $wpdb->linkcategories WHERE cat_id=1 ";
     167    $result = mysql_query($sql) or print ("Can't query '$wpdb->linkcategories'.<br />" . $sql . "<br />" . mysql_error());
    168168    if ($result != false) {
    169169        if ($row = mysql_fetch_object($result)) {
    … …  
    172172        } else {
    173173            echo "<p>Gonna insert category 1...</p>\n";
    174             $sql = "INSERT INTO $tablelinkcategories (cat_id, cat_name) VALUES (1, 'General')";
     174            $sql = "INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, 'General')";
    175175            $result = mysql_query($sql) or print ("Can't query insert category.<br />" . $sql . "<br />" . mysql_error());
    176176            if ($result != false) {
    … …  
    197197<?php
    198198
    199 $query = "ALTER TABLE $tableposts ADD COLUMN post_excerpt text NOT NULL;";
     199$query = "ALTER TABLE $wpdb->posts ADD COLUMN post_excerpt text NOT NULL;";
    200200$q = $wpdb->query($query);
    201201// 0.71 mods
    202 $query = "ALTER TABLE $tableposts ADD post_status ENUM('publish','draft','private') NOT NULL,
     202$query = "ALTER TABLE $wpdb->posts ADD post_status ENUM('publish','draft','private') NOT NULL,
    203203ADD comment_status ENUM('open','closed') NOT NULL,
    204204ADD ping_status ENUM('open','closed') NOT NULL,
    … …  
    210210
    211211<?php
    212 $query = "ALTER TABLE $tableposts DROP INDEX ID";
     212$query = "ALTER TABLE $wpdb->posts DROP INDEX ID";
    213213
    214214$q = $wpdb->query($query);
    … …  
    218218<p>One down, two to go...</p>
    219219
    220 <?php
    221 
    222 $query="ALTER TABLE $tablesettings DROP INDEX ID";
    223 $q = $wpdb->query($query);
    224 
    225 ?>
    226220
    227221<p>So far so good.</p>
    228222<?php
    229223
    230 $query="ALTER TABLE $tableposts DROP post_karma";
     224$query="ALTER TABLE $wpdb->posts DROP post_karma";
    231225$q = $wpdb->query($query);
    232226flush();
    … …  
    237231<?php
    238232
    239 $query = "ALTER TABLE $tableusers DROP INDEX ID";
     233$query = "ALTER TABLE $wpdb->users DROP INDEX ID";
    240234
    241235$q = $wpdb->query($query);
  • trunk/wp-admin/import-blogger.php

    r1285 r1355  
    6464                        $post_author = trim(addslashes($postinfo[1]));
    6565                        // we'll check the author is registered already
    66                         $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$post_author'");
     66                        $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$post_author'");
    6767                        if (!$user) { // seems s/he's not, so let's register
    6868                                $user_ip = '127.0.0.1';
    … …  
    7777                                $user_joindate = addslashes($user_joindate);
    7878                                $result = $wpdb->query("
    79                                 INSERT INTO $tableusers (
     79                                INSERT INTO $wpdb->users (
    8080                                        user_login,
    8181                                        user_pass,
    … …  
    106106                        }
    107107
    108                         $post_author_ID = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$post_author'");
     108                        $post_author_ID = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$post_author'");
    109109
    110110                        $post_date = explode(' ', $post_date);
    … …  
    129129                       
    130130                        // Quick-n-dirty check for dups:
    131                         $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A);
     131                        $dupcheck = $wpdb->get_results("SELECT ID,post_date,post_title FROM $wpdb->posts WHERE post_date='$post_date' AND post_title='$post_title' LIMIT 1",ARRAY_A);
    132132                        if ($dupcheck[0]['ID']) {
    133133                                print "<br />\nSkipping duplicate post, ID = '" . $dupcheck[0]['ID'] . "'<br />\n";
    … …  
    138138
    139139                        $result = $wpdb->query("
    140                         INSERT INTO $tableposts
     140                        INSERT INTO $wpdb->posts
    141141                                (post_author,post_date,post_content,post_title,post_category)
    142142                        VALUES
    … …  
    152152        /* we've still got a bug that adds some empty posts with the date 0000-00-00 00:00:00
    153153           here's the bugfix: */
    154         $result = $wpdb->query("DELETE FROM $tableposts WHERE post_date=\"0000-00-00 00:00:00\"");
     154        $result = $wpdb->query("DELETE FROM $wpdb->posts WHERE post_date=\"0000-00-00 00:00:00\"");
    155155
    156156        upgrade_all();
  • trunk/wp-admin/import-greymatter.php

    r1190 r1355  
    8888                $user_joindate=addslashes($user_joindate);
    8989
    90                 $loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
     90                $loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
    9191                if ($loginthere) {
    9292                        echo "<li>user <i>$user_login</i>... <b>Already exists</b></li>";
    … …  
    9494                }
    9595
    96                 $query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')";
     96                $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','1','nickname')";
    9797                $result = mysql_query($query);
    9898                if ($result==false) {
    … …  
    140140                        $post_author=trim(addslashes($postinfo[1]));
    141141                        // we'll check the author is registered, or if it's a deleted author
    142                         $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
     142                        $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
    143143                        $result = mysql_query($sql);
    144144                        if (!mysql_num_rows($result)) { // if deleted from GM, we register the author as a level 0 user in b2
    … …  
    153153                                $user_url=addslashes("");
    154154                                $user_joindate=addslashes($user_joindate);
    155                                 $query = "INSERT INTO $tableusers (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')";
     155                                $query = "INSERT INTO $wpdb->users (user_login,user_pass,user_nickname,user_email,user_url,user_ip,user_domain,user_browser,dateYMDhour,user_level,user_idmode) VALUES ('$user_login','$pass1','$user_nickname','$user_email','$user_url','$user_ip','$user_domain','$user_browser','$user_joindate','0','nickname')";
    156156                                $result = mysql_query($query);
    157157                                if ($result==false) {
    … …  
    161161                        }
    162162
    163                         $sql = "SELECT * FROM $tableusers WHERE user_login = '$post_author'";
     163                        $sql = "SELECT * FROM $wpdb->users WHERE user_login = '$post_author'";
    164164                        $result = mysql_query($sql);
    165165                        $myrow = mysql_fetch_array($result);
    … …  
    188188                        $post_karma=$postinfo[12];
    189189
    190                         $query = "INSERT INTO $tableposts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')";
     190                        $query = "INSERT INTO $wpdb->posts (post_author,post_date,post_content,post_title) VALUES ('$post_author_ID','$post_date','$post_content','$post_title')";
    191191                        $result = mysql_query($query) or die(mysql_error());
    192192
    … …  
    194194                                die ("Error in posting...");
    195195                       
    196                         $sql2 = "SELECT * FROM $tableposts WHERE 1=1 ORDER BY ID DESC LIMIT 1";
     196                        $sql2 = "SELECT * FROM $wpdb->posts WHERE 1=1 ORDER BY ID DESC LIMIT 1";
    197197                        $result2 = mysql_query($sql2);
    198198                        $myrow2 = mysql_fetch_array($result2);
    … …  
    200200
    201201                        // Grab a default category.
    202                         $post_category = $wpdb->get_var("SELECT cat_ID FROM $tablecategories LIMIT 1");
     202                        $post_category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
    203203
    204204                        // Update the post2cat table.
    205                         $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category");
     205                        $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category");
    206206                         
    207207                        if (!$exists) {
    208208                          $wpdb->query("
    209                                         INSERT INTO $tablepost2cat
     209                                        INSERT INTO $wpdb->post2cat
    210210                                        (post_id, category_id)
    211211                                        VALUES
    … …  
    237237                                        $comment_content=addslashes($commentinfo[12]);
    238238
    239                                         $sql3 = "INSERT INTO $tablecomments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
     239                                        $sql3 = "INSERT INTO $wpdb->comments (comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_author_IP,comment_date,comment_content) VALUES ('$comment_post_ID','$comment_author','$comment_author_email','$comment_author_url','$comment_author_IP','$comment_date','$comment_content')";
    240240                                        $result3 = mysql_query($sql3);
    241241                                        if (!$result3)
  • trunk/wp-admin/import-livejournal.php

    r1147 r1355  
    9595
    9696// Now lets put it in the DB
    97 if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'")) :
     97if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'")) :
    9898        echo 'Post already imported';
    9999else :
    100100       
    101         $wpdb->query("INSERT INTO $tableposts
     101        $wpdb->query("INSERT INTO $wpdb->posts
    102102                (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name)
    103103                VALUES
    104104                ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name')");
    105         $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'");
     105        $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
    106106        if (!$post_id) die("couldn't get post ID");
    107         $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1");
    108         if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) ");
     107        $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
     108        if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
    109109        echo 'Done!</li>';
    110110endif;
  • trunk/wp-admin/import-mt.php

    r1292 r1355  
    7272
    7373function users_form($n) {
    74         global $wpdb, $tableusers, $testing;
    75         $users = $wpdb->get_results("SELECT * FROM $tableusers ORDER BY ID");
     74        global $wpdb, $testing;
     75        $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
    7676        ?><select name="userselect[<?php echo $n; ?>]">
    7777        <option value="#NONE#">- Select -</option>
    … …  
    148148        //function to check the authorname and do the mapping
    149149        function checkauthor($author) {
    150         global $wpdb, $tableusers, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file
     150        global $wpdb, $mtnames, $newauthornames, $j;//mtnames is an array with the names in the mt import file
    151151        $md5pass = md5(changeme);
    152152        if (!(in_array($author, $mtnames))) { //a new mt author name is found
    153153                ++$j;
    154154                $mtnames[$j] = $author; //add that new mt author name to an array
    155                 $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user
     155                $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'"); //check if the new author name defined by the user is a pre-existing wp user
    156156                if (!$user_id) { //banging my head against the desk now.
    157157                        if ($newauthornames[$j] == 'left_blank') { //check if the user does not want to change the authorname
    158                                 $wpdb->query("INSERT INTO $tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author
    159                                 $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$author'");
     158                                $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$author', '$md5pass', '$author')"); // if user does not want to change, insert the authorname $author
     159                                $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$author'");
    160160                                $newauthornames[$j] = $author; //now we have a name, in the place of left_blank.
    161161                        } else {
    162                         $wpdb->query("INSERT INTO $tableusers (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name
    163                         $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$j]'");
     162                        $wpdb->query("INSERT INTO $wpdb->users (user_level, user_login, user_pass, user_nickname) VALUES ('1', '$newauthornames[$j]', '$md5pass', '$newauthornames[$j]')"); //if not left_blank, insert the user specified name
     163                        $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$j]'");
    164164                        }
    165165                } else return $user_id; // return pre-existing wp username if it exists
    166166    } else {
    167167    $key = array_search($author, $mtnames); //find the array key for $author in the $mtnames array
    168     $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames
     168    $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$newauthornames[$key]'");//use that key to get the value of the author's name from $newauthornames
    169169        }
    170170        return $user_id;
    … …  
    273273
    274274        // Let's check to see if it's in already
    275         if ($wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'")) {
     275        if ($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'")) {
    276276                echo "Post already imported.";
    277277        } else {
    278278                $post_author = checkauthor($post_author);//just so that if a post already exists, new users are not created by checkauthor
    279             $wpdb->query("INSERT INTO $tableposts (
     279            $wpdb->query("INSERT INTO $wpdb->posts (
    280280                        post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt)
    281281                        VALUES
    282282                        ('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$excerpt', '$post_status', '$comment_status', '$ping_status', '$post_name','$post_date', '$post_date_gmt')");
    283                 $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$post_title' AND post_date = '$post_date'");
     283                $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$post_title' AND post_date = '$post_date'");
    284284                if (0 != count($post_categories)) {
    285285                        foreach ($post_categories as $post_category) {
    286286                        // See if the category exists yet
    287                         $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
     287                        $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
    288288                        if (!$cat_id && '' != trim($post_category)) {
    289289                                $cat_nicename = sanitize_title($post_category);
    290                                 $wpdb->query("INSERT INTO $tablecategories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
    291                                 $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
     290                                $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
     291                                $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
    292292                        }
    293293                        if ('' == trim($post_category)) $cat_id = 1;
    294294                        // Double check it's not there already
    295                         $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = $cat_id");
     295                        $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id");
    296296
    297297                         if (!$exists) {
    298298                                $wpdb->query("
    299                                 INSERT INTO $tablepost2cat
     299                                INSERT INTO $wpdb->post2cat
    300300                                (post_id, category_id)
    301301                                VALUES
    … …  
    305305                } // end category loop
    306306                } else {
    307                         $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1");
    308                         if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) ");
     307                        $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
     308                        if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
    309309                }
    310310                echo " Post imported successfully...";
    … …  
    339339
    340340                        // Check if it's already there
    341                         if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
    342                                 $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
     341                        if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
     342                                $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
    343343                                VALUES
    344344                                ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')");
    … …  
    384384     
    385385                        // Check if it's already there
    386                         if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
    387                                 $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
     386                        if (!$wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
     387                                $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
    388388                                VALUES
    389389                                ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')");
  • trunk/wp-admin/import-rss.php

    r1264 r1355  
    125125// So we do it as a last resort
    126126if ('' == $title) :
    127         $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_content = '$content' AND post_date = '$post_date'");
     127        $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_content = '$content' AND post_date = '$post_date'");
    128128else :
    129         $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'");
     129        $dupe = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
    130130endif;
    131131
    … …  
    135135else :
    136136       
    137         $wpdb->query("INSERT INTO $tableposts
     137        $wpdb->query("INSERT INTO $wpdb->posts
    138138                (post_author, post_date, post_date_gmt, post_content, post_title,post_status, comment_status, ping_status, post_name)
    139139                VALUES
    140140                ('$post_author', '$post_date', DATE_ADD('$post_date', INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE), '$content', '$title', 'publish', '$comment_status', '$ping_status', '$post_name')");
    141         $post_id = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'");
     141        $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$title' AND post_date = '$post_date'");
    142142        if (!$post_id) die("couldn't get post ID");
    143143        if (0 != count($categories)) :
    … …  
    145145                $post_category = unhtmlentities($post_category);
    146146                // See if the category exists yet
    147                 $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
     147                $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
    148148                if (!$cat_id && '' != trim($post_category)) {
    149149                        $cat_nicename = sanitize_title($post_category);
    150                         $wpdb->query("INSERT INTO $tablecategories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
    151                         $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
     150                        $wpdb->query("INSERT INTO $wpdb->categories (cat_name, category_nicename) VALUES ('$post_category', '$cat_nicename')");
     151                        $cat_id = $wpdb->get_var("SELECT cat_ID from $wpdb->categories WHERE cat_name = '$post_category'");
    152152                }
    153153                if ('' == trim($post_category)) $cat_id = 1;
    154154                // Double check it's not there already
    155                 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = $cat_id");
     155                $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = $cat_id");
    156156       
    157157                 if (!$exists) {
    158158                        $wpdb->query("
    159                         INSERT INTO $tablepost2cat
     159                        INSERT INTO $wpdb->post2cat
    160160                        (post_id, category_id)
    161161                        VALUES
    … …  
    165165        endforeach;
    166166        else:
    167                 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_id AND category_id = 1");
    168                 if (!$exists) $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_id, 1) ");
     167                $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_id AND category_id = 1");
     168                if (!$exists) $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_id, 1) ");
    169169        endif;
    170170        echo 'Done!</li>';
  • trunk/wp-admin/import-textpattern.php

    r1117 r1355  
    7272<?php
    7373// For people running this on .72
    74 $query = "ALTER TABLE `$tableposts` ADD `post_name` VARCHAR(200) NOT NULL";
    75 maybe_add_column($tableposts, 'post_name', $query);
     74$query = "ALTER TABLE `$wpdb->posts` ADD `post_name` VARCHAR(200) NOT NULL";
     75maybe_add_column($wpdb->posts, 'post_name', $query);
    7676
    7777// Create post_name field
    … …  
    8080
    8181// For now we're going to give everything the same author and same category
    82 $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_level = 10 LIMIT 1");
    83 $category = $wpdb->get_var("SELECT cat_ID FROM $tablecategories LIMIT 1");
     82$author = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_level = 10 LIMIT 1");
     83$category = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories LIMIT 1");
    8484
    8585$posts = mysql_query('SELECT * FROM textpattern', $connection);
    … …  
    102102        $post_name = sanitize_title($title);
    103103
    104         $wpdb->query("INSERT INTO $tableposts
     104        $wpdb->query("INSERT INTO $wpdb->posts
    105105                (post_author, post_date, post_content, post_title, post_category, post_name, post_status)
    106106                VALUES
    … …  
    108108
    109109        // Get wordpress post id
    110         $wp_post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1");
     110        $wp_post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1");
    111111       
    112112        // Now let's insert comments if there are any for the TP post
    … …  
    118118                        // For some reason here "posted" is a real MySQL date, so we don't have to do anything about it
    119119                        //  comment_post_ID      comment_author          comment_author_email    comment_author_url      comment_author_IP       comment_date    comment_content         comment_karma
    120                         $wpdb->query("INSERT INTO $tablecomments
     120                        $wpdb->query("INSERT INTO $wpdb->comments
    121121                                (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content)
    122122                                VALUES
  • trunk/wp-admin/install-helper.php

    r601 r1355  
    132132
    133133//check_column('wp_links', 'link_description', 'mediumtext');
    134 //if (check_column($tablecomments, 'comment_author', 'tinytext'))
     134//if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
    135135//    echo "ok\n";
    136136$error_count = 0;
    137 $tablename = $tablelinks;
     137$tablename = $wpdb->links;
    138138// check the column
    139 if (!check_column($tablelinks, 'link_description', 'varchar(255)'))
     139if (!check_column($wpdb->links, 'link_description', 'varchar(255)'))
    140140{
    141     $ddl = "ALTER TABLE $tablelinks MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
     141    $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
    142142    $q = $wpdb->query($ddl);
    143143}
    144 if (check_column($tablelinks, 'link_description', 'varchar(255)')) {
     144if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
    145145    $res .= $tablename . ' - ok <br />';
    146146} else {
  • trunk/wp-admin/install.php

    r1308 r1355  
    5151
    5252$wpdb->hide_errors();
    53 $installed = $wpdb->get_results("SELECT * FROM $tableusers");
     53$installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
    5454if ($installed) die(__('<p>You appear to already have WordPress installed. If you would like to reinstall please clear your old database files first.</p></body></html>'));
    5555$wpdb->show_errors();
    … …  
    8989
    9090while ($row = mysql_fetch_row($result)) {
    91     if ($row[0] == $tablelinks)
     91    if ($row[0] == $wpdb->links)
    9292        $got_links = true;
    93     if ($row[0] == $tablelinkcategories)
     93    if ($row[0] == $wpdb->linkcategories)
    9494        $got_cats = true;
    9595    //print "Table: $row[0]<br />\n";
    9696}
    9797if (!$got_cats) {
    98     echo "<p>Can't find table '$tablelinkcategories', gonna create it...</p>\n";
    99     $sql = "CREATE TABLE $tablelinkcategories ( " .
     98    echo "<p>Can't find table '$wpdb->linkcategories', gonna create it...</p>\n";
     99    $sql = "CREATE TABLE $wpdb->linkcategories ( " .
    100100           " cat_id int(11) NOT NULL auto_increment, " .
    101101           " cat_name tinytext NOT NULL, ".
    … …  
    113113           " PRIMARY KEY (cat_id) ".
    114114           ") ";
    115     $result = mysql_query($sql) or print ("Can't create the table '$tablelinkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
     115    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->linkcategories' in the database.<br />" . $sql . "<br />" . mysql_error());
    116116    if ($result != false) {
    117         echo "<p>Table '$tablelinkcategories' created OK</p>\n";
     117        echo "<p>Table '$wpdb->linkcategories' created OK</p>\n";
    118118        $got_cats = true;
    119119    }
    120120} else {
    121     echo "<p>Found table '$tablelinkcategories', don't need to create it...</p>\n";
     121    echo "<p>Found table '$wpdb->linkcategories', don't need to create it...</p>\n";
    122122        $got_cats = true;
    123123}
    124124if (!$got_links) {
    125     echo "<p>Can't find '$tablelinks', gonna create it...</p>\n";
    126     $sql = "CREATE TABLE $tablelinks ( " .
     125    echo "<p>Can't find '$wpdb->links', gonna create it...</p>\n";
     126    $sql = "CREATE TABLE $wpdb->links ( " .
    127127           " link_id int(11) NOT NULL auto_increment,           " .
    128128           " link_url varchar(255) NOT NULL default '',         " .
    … …  
    140140           " PRIMARY KEY (link_id)                              " .
    141141           ") ";
    142     $result = mysql_query($sql) or print ("Can't create the table '$tablelinks' in the database.<br />" . $sql . "<br />" . mysql_error());
    143         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
    144         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
    145         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://zed1.com/journalized/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
    146         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://www.alexking.org/', 'Alex', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
    147         $links = mysql_query("INSERT INTO $tablelinks VALUES ('', 'http://dougal.gunters.org/', 'Dougal', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
     142    $result = mysql_query($sql) or print ("Can't create the table '$wpdb->links' in the database.<br />" . $sql . "<br />" . mysql_error());
     143        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://wordpress.org/', 'WordPress', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
     144        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://photomatt.net/', 'Matt', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
     145        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://zed1.com/journalized/', 'Mike', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
     146        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://www.alexking.org/', 'Alex', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
     147        $links = mysql_query("INSERT INTO $wpdb->links VALUES ('', 'http://dougal.gunters.org/', 'Dougal', '', '', 1, '', 'Y', 1, 0, '0000-00-00 00:00:00', '', '');");
    148148
    149149
    150150    if ($result != false) {
    151         echo "<p>Table '$tablelinks' created OK</p>\n";
     151        echo "<p>Table '$wpdb->links' created OK</p>\n";
    152152        $got_links = true;
    153153    }
    154154} else {
    155     echo "<p>Found table '$tablelinks', don't need to create it...</p>\n";
     155    echo "<p>Found table '$wpdb->links', don't need to create it...</p>\n";
    156156        $got_links = true;
    157157}
    … …  
    159159if ($got_links && $got_cats) {
    160160    echo "<p>Looking for category 1...</p>\n";
    161     $sql = "SELECT * FROM $tablelinkcategories WHERE cat_id=1 ";
    162     $result = mysql_query($sql) or print ("Can't query '$tablelinkcategories'.<br />" . $sql . "<br />" . mysql_error());
     161    $sql = "SELECT * FROM $wpdb->linkcategories WHERE cat_id=1 ";
     162    $result = mysql_query($sql) or print ("Can't query '$wpdb->linkcategories'.<br />" . $sql . "<br />" . mysql_error());
    163163    if ($result != false) {
    164164        if ($row = mysql_fetch_object($result)) {
    … …  
    167167        } else {
    168168            echo "<p>Gonna insert category 1...</p>\n";
    169             $sql = "INSERT INTO $tablelinkcategories (cat_id, cat_name) VALUES (1, 'Links')";
     169            $sql = "INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, 'Links')";
    170170            $result = mysql_query($sql) or print ("Can't query insert category.<br />" . $sql . "<br />" . mysql_error());
    171171            if ($result != false) {
    … …  
    194194#       just remove the // in this file
    195195
    196 // $query = "DROP TABLE IF EXISTS $tableposts";
    197 // $q = mysql_query($query) or die ("doh, can't drop the table \"$tableposts\" in the database.");
    198 
    199 $query = "CREATE TABLE $tableposts (
     196// $query = "DROP TABLE IF EXISTS $wpdb->posts";
     197// $q = mysql_query($query) or die ("doh, can't drop the table \"$wpdb->posts\" in the database.");
     198
     199$query = "CREATE TABLE $wpdb->posts (
    200200  ID int(10) unsigned NOT NULL auto_increment,
    201201  post_author int(4) NOT NULL default '0',
    … …  
    233233$now = date('Y-m-d H:i:s');
    234234$now_gmt = gmdate('Y-m-d H:i:s');
    235 $query = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', 'Welcome to WordPress. This is the first post. Edit or delete it, then start blogging!', 'Hello world!', '$now', '$now_gmt')";
     235$query = "INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES ('1', '$now', '$now_gmt', 'Welcome to WordPress. This is the first post. Edit or delete it, then start blogging!', 'Hello world!', '$now', '$now_gmt')";
    236236
    237237$q = $wpdb->query($query);
    … …  
    241241
    242242<?php
    243 // $query = "DROP TABLE IF EXISTS $tablecategories";
    244 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tablecategories\" in the database.");
    245 
    246 $query = "
    247 CREATE TABLE $tablecategories (
     243// $query = "DROP TABLE IF EXISTS $wpdb->categories";
     244// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->categories\" in the database.");
     245
     246$query = "
     247CREATE TABLE $wpdb->categories (
    248248  cat_ID int(4) NOT NULL auto_increment,
    249249  cat_name varchar(55) NOT NULL default '',
    … …  
    254254$q = $wpdb->query($query);
    255255
    256 $query = "INSERT INTO $tablecategories (cat_ID, cat_name) VALUES ('0', 'General')";
    257 $q = $wpdb->query($query);
    258 
    259 $query = "UPDATE $tableposts SET post_category = 1";
     256$query = "INSERT INTO $wpdb->categories (cat_ID, cat_name) VALUES ('0', 'General')";
     257$q = $wpdb->query($query);
     258
     259$query = "UPDATE $wpdb->posts SET post_category = 1";
    260260$result = $wpdb->query($query);
    261261?>
    … …  
    264264
    265265<?php
    266 // $query = "DROP TABLE IF EXISTS $tablecomments";
    267 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tablecomments\" in the database.");
    268 
    269 $query = "
    270 CREATE TABLE $tablecomments (
     266// $query = "DROP TABLE IF EXISTS $wpdb->comments";
     267// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->comments\" in the database.");
     268
     269$query = "
     270CREATE TABLE $wpdb->comments (
    271271  comment_ID int(11) unsigned NOT NULL auto_increment,
    272272  comment_post_ID int(11) NOT NULL default '0',
    … …  
    294294<?php
    295295$query = "
    296         CREATE TABLE $tablepostmeta (
     296        CREATE TABLE $wpdb->postmeta (
    297297          meta_id int(11) NOT NULL auto_increment,
    298298          post_id int(11) NOT NULL default 0,
    … …  
    313313
    314314<?php
    315 // $query = "DROP TABLE IF EXISTS $tableoptions";
    316 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tableoptions\" in the database.");
    317 
    318 $query = "
    319 CREATE TABLE $tableoptions (
     315// $query = "DROP TABLE IF EXISTS $wpdb->options";
     316// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->options\" in the database.");
     317
     318$query = "
     319CREATE TABLE $wpdb->options (
    320320  option_id int(11) NOT NULL auto_increment,
    321321  blog_id int(11) NOT NULL default 0,
    … …  
    337337
    338338$query = "
    339 CREATE TABLE $tableoptiontypes (
     339CREATE TABLE $wpdb->optiontypes (
    340340  optiontype_id int(11) NOT NULL auto_increment,
    341341  optiontype_name varchar(64) NOT NULL,
    … …  
    350350
    351351$query = "
    352 CREATE TABLE $tableoptiongroups (
     352CREATE TABLE $wpdb->optiongroups (
    353353  group_id int(11) NOT NULL auto_increment,
    354354  group_name varchar(64) not null,
    … …  
    361361
    362362
    363 // $query = "DROP TABLE IF EXISTS $tableoptiongroup_options";
    364 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tableoptiongroup_options\" in the database.");
    365 
    366 $query = "
    367 CREATE TABLE $tableoptiongroup_options (
     363// $query = "DROP TABLE IF EXISTS $wpdb->optiongroup_options";
     364// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->optiongroup_options\" in the database.");
     365
     366$query = "
     367CREATE TABLE $wpdb->optiongroup_options (
    368368  group_id int(11) NOT NULL,
    369369  option_id int(11) NOT NULL,
    … …  
    375375
    376376
    377 // $query = "DROP TABLE IF EXISTS $tableoptionvalues";
    378 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tableoptionvalues\" in the database.");
    379 
    380 $query = "
    381 CREATE TABLE $tableoptionvalues (
     377// $query = "DROP TABLE IF EXISTS $wpdb->optionvalues";
     378// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->optionvalues\" in the database.");
     379
     380$query = "
     381CREATE TABLE $wpdb->optionvalues (
    382382  option_id int(11) NOT NULL,
    383383  optionvalue tinytext,
    … …  
    399399
    400400$option_data = array(
    401 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (1, 'integer')",
    402 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (2, 'boolean')",
    403 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (3, 'string')",
    404 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (4, 'date')",
    405 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (5, 'select')",
    406 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (6, 'range')",
    407 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (7, 'sqlselect')",
    408 "INSERT INTO $tableoptiontypes (optiontype_id, optiontype_name) VALUES (8, 'float')",
     401"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (1, 'integer')",
     402"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (2, 'boolean')",
     403"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (3, 'string')",
     404"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (4, 'date')",
     405"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (5, 'select')",
     406"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (6, 'range')",
     407"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (7, 'sqlselect')",
     408"INSERT INTO $wpdb->optiontypes (optiontype_id, optiontype_name) VALUES (8, 'float')",
    409409
    410410//base options from b2cofig
    411 "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(1,'siteurl', 3, 'http://example.com', 'siteurl is your blog\'s URL: for example, \'http://example.com/wordpress\' (no trailing slash !)', 8, 30)",
    412 "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)",
    413 "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)",
    414 "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)",
    415 //"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)",
    416 "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)",
    417 "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)",
    418 "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)",
    419 "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES (93, 'blog_charset', 3, 'utf-8', 'Your blog&#8217;s charset (here&#8217;s a <a href=\'http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html\'>list of possible charsets</a>)', 8)",
     411"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(1,'siteurl', 3, 'http://example.com', 'siteurl is your blog\'s URL: for example, \'http://example.com/wordpress\' (no trailing slash !)', 8, 30)",
     412"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)",
     413"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)",
     414"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)",
     415//"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)",
     416"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)",
     417"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)",
     418"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)",
     419"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES (93, 'blog_charset', 3, 'utf-8', 'Your blog&#8217;s charset (here&#8217;s a <a href=\'http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html\'>list of possible charsets</a>)', 8)",
    420420// general blog setup
    421 "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)",
    422 //"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)",
    423 "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)",
    424 "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)",
    425 "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 1 to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8, 20)",
    426 "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)",
    427 "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)",
     421"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)",
     422//"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)",
     423"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)",
     424"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)",
     425"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 1 to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8, 20)",
     426"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)",
     427"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)",
    428428//rss/rdf feeds
    429 "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)",
    430 "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)",
    431 "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)",
    432 "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)",
    433 "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)",
    434 "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 0 or 1, whether you want to allow your posts to be trackback\'able or not note: setting it to zero would also disable sending trackbacks', 8, 20)",
    435 "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 0 or 1, whether you want to allow your posts to be pingback\'able or not note: setting it to zero would also disable sending pingbacks', 8, 20)",
     429"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)",
     430"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)",
     431"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)",
     432"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)",
     433"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)",
     434"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 0 or 1, whether you want to allow your posts to be trackback\'able or not note: setting it to zero would also disable sending trackbacks', 8, 20)",
     435"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 0 or 1, whether you want to allow your posts to be pingback\'able or not note: setting it to zero would also disable sending pingbacks', 8, 20)",
    436436//file upload
    437 "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)",
    438 "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)",
    439 "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)",
    440 "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(34,'fileupload_allowedtypes', 3, 'jpg jpeg gif png', 'accepted file types, separated by spaces. example: \'jpg gif png\'', 8, 20)",
    441 "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)",
    442 "INSERT INTO $tableoptions (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(36,'fileupload_minlevel', 1, '4', 'you may not want all users to upload pictures/files, so you can set a minimum level for this', 8, 20)",
    443 "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)",
     437"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)",
     438"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)",
     439"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)",
     440"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 jpeg gif png', 'accepted file types, separated by spaces. example: \'jpg gif png\'', 8, 20)",
     441"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)",
     442"INSERT INTO $wpdb->options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(36,'fileupload_minlevel', 1, '4', 'you may not want all users to upload pictures/files, so you can set a minimum level for this', 8, 20)",
     443"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)",
    444444// email settings
    445 "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)",
    446 "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)",
    447 "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)",
    448 "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)",
    449 "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)",
    450 "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)",
     445"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)",
     446"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)",
     447"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)",
     448"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)",
     449"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)",
     450"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)",
    451451// original options from options page
    452 "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)",
    453 "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)",
    454 "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)",
    455 "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)",
    456 "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)",
    457 "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)",
     452"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)",
     453"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)",
     454"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)",
     455"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)",
     456"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)",
     457"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)",
    458458
    459459//'pages' of options
    460 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(1, 'Other Options', 'Posts per page etc. Original options page')",
    461 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,48,1 )",
    462 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,49,2 )",
    463 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,50,3 )",
    464 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,51,4 )",
    465 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,52,5 )",
    466 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(1,53,6 )",
    467 
    468 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(2, 'General blog settings', 'Things you\'ll probably want to tweak')",
    469 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,9 ,1 )",
    470 //"INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,10,2 )",
    471 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,11,3 )",
    472 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,12,4 )",
    473 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,13,5 )",
    474 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,14,6 )",
    475 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,15,7 )",
    476 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,16,8 )",
    477 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,17,9 )",
    478 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,18,10)",
    479 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,19,11)",
    480 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(2,20,12)",
    481 
    482 "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')",
    483 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,21,1 )",
    484 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,22,2 )",
    485 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,23,3 )",
    486 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,24,4 )",
    487 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,25,5 )",
    488 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,26,6 )",
    489 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,27,7 )",
    490 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,28,8 )",
    491 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,29,9 )",
    492 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(3,30,10)",
    493 
    494 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(4, 'File uploads', 'Settings for file uploads')",
    495 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,31,1 )",
    496 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,32,2 )",
    497 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,33,3 )",
    498 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,34,4 )",
    499 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,35,5 )",
    500 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,36,6 )",
    501 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(4,37,7 )",
    502 
    503 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(5, 'Blog-by-Email settings', 'Settings for blogging via email')",
    504 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,38,1 )",
    505 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,39,2 )",
    506 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,40,3 )",
    507 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,41,4 )",
    508 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,42,5 )",
    509 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,43,6 )",
    510 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,44,7 )",
    511 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,45,8 )",
    512 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,46,9 )",
    513 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(5,47,10)",
    514 
    515 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(6, 'Base settings', 'Basic settings required to get your blog working')",
    516 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,1,1)",
    517 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,2,2)",
    518 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,3,3)",
    519 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,4,4)",
    520 //"INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,6,5)",
    521 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,7,6)",
    522 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,8,7)",
    523 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(6,54,8)",
     460"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(1, 'Other Options', 'Posts per page etc. Original options page')",
     461"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,48,1 )",
     462"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,49,2 )",
     463"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,50,3 )",
     464"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,51,4 )",
     465"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,52,5 )",
     466"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(1,53,6 )",
     467
     468"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(2, 'General blog settings', 'Things you\'ll probably want to tweak')",
     469"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,9 ,1 )",
     470//"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,10,2 )",
     471"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,11,3 )",
     472"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,12,4 )",
     473"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,13,5 )",
     474"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,14,6 )",
     475"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,15,7 )",
     476"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,16,8 )",
     477"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,17,9 )",
     478"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,18,10)",
     479"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,19,11)",
     480"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(2,20,12)",
     481
     482"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')",
     483"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,21,1 )",
     484"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,22,2 )",
     485"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,23,3 )",
     486"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,24,4 )",
     487"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,25,5 )",
     488"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,26,6 )",
     489"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,27,7 )",
     490"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,28,8 )",
     491"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,29,9 )",
     492"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(3,30,10)",
     493
     494"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(4, 'File uploads', 'Settings for file uploads')",
     495"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,31,1 )",
     496"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,32,2 )",
     497"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,33,3 )",
     498"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,34,4 )",
     499"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,35,5 )",
     500"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,36,6 )",
     501"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(4,37,7 )",
     502
     503"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(5, 'Blog-by-Email settings', 'Settings for blogging via email')",
     504"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,38,1 )",
     505"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,39,2 )",
     506"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,40,3 )",
     507"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,41,4 )",
     508"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,42,5 )",
     509"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,43,6 )",
     510"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,44,7 )",
     511"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,45,8 )",
     512"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,46,9 )",
     513"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(5,47,10)",
     514
     515"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(6, 'Base settings', 'Basic settings required to get your blog working')",
     516"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,1,1)",
     517"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,2,2)",
     518"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,3,3)",
     519"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,4,4)",
     520//"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,6,5)",
     521"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,7,6)",
     522"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,8,7)",
     523"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(6,54,8)",
    524524
    525525// select data for what to show
    526 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days',  'days',        null,null,1)",
    527 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts',       null,null,2)",
    528 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
     526"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days',  'days',        null,null,1)",
     527"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts',       null,null,2)",
     528"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'paged', 'posts paged', null,null,3)",
    529529// select data for archive mode
    530 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily',     'daily',       null,null,1)",
    531 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly',    'weekly',      null,null,2)",
    532 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly',   'monthly',     null,null,3)",
    533 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)",
     530"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'daily',     'daily',       null,null,1)",
     531"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'weekly',    'weekly',      null,null,2)",
     532"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'monthly',   'monthly',     null,null,3)",
     533"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (50, 'postbypost','post by post',null,null,4)",
    534534// select data for time diff
    535 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)",
     535"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (51, 'hours', 'hours', 23, -23, null)",
    536536// select data for start of week
    537 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday',   null,null,1)",
    538 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday',   null,null,2)",
    539 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)",
     537"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '0', 'Sunday',   null,null,1)",
     538"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday',   null,null,2)",
     539"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3)",
    540540
    541541
    … …  
    546546// default_ping_status select one of open closed
    547547// default_pingback_flag select one of checked unchecked
    548 // default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $tablecategories order by cat_name"
    549 
    550 "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)",
    551 "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)",
    552 "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)",
    553 "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)",
    554 "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)",
    555 "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)",
    556 
    557 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(7, 'Default post options', 'Default settings for new posts.')",
    558 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,55,1 )",
    559 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,56,2 )",
    560 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,57,3 )",
    561 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,58,4 )",
    562 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,59,5 )",
    563 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(7,83,5 )",
     548// default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $wpdb->categories order by cat_name"
     549
     550"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)",
     551"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)",
     552"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)",
     553"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)",
     554"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)",
     555"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)",
     556
     557"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(7, 'Default post options', 'Default settings for new posts.')",
     558"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,55,1 )",
     559"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,56,2 )",
     560"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,57,3 )",
     561"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,58,4 )",
     562"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,59,5 )",
     563"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(7,83,5 )",
    564564
    565565// select data for post_status
    566 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)",
    567 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft',   'Draft',   null,null,2)",
    568 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)",
     566"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1)",
     567"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft',   'Draft',   null,null,2)",
     568"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3)",
    569569
    570570// select data for comment_status
    571 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open',   null,null,1)",
    572 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)",
     571"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open',   null,null,1)",
     572"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2)",
    573573
    574574// select data for ping_status (aargh duplication!)
    575 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open',   null,null,1)",
    576 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)",
     575"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open',   null,null,1)",
     576"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2)",
    577577
    578578// select data for pingback flag
    579 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked',   null,null,1)",
    580 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)",
     579"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked',   null,null,1)",
     580"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2)",
    581581
    582582// sql select data for default
    583 "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)",
     583"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)",
    584584);
    585585
    … …  
    594594<?php
    595595$links_option_data = array(
    596 "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)",
    597 "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)",
    598 "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)",
    599 "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)",
    600 "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)",
    601 "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)",
    602 "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)",
    603 "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)",
    604 "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)",
    605 "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)",
    606 "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)",
    607 "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)",
    608 "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)",
    609 "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)",
    610 "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)",
    611 "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)",
    612 "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)",
    613 "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)",
    614 "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)",
    615 "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)",
    616 "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)",
    617 "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)",
     596"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)",
     597"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)",
     598"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)",
     599"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)",
     600"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)",
     601"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)",
     602"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)",
     603"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)",
     604"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)",
     605"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)",
     606"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)",
     607"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)",
     608"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)",
     609"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)",
     610"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)",
     611"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)",
     612"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)",
     613"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)",
     614"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)",
     615"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)",
     616"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)",
     617"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)",
    618618
    619619//group them together
    620 "INSERT INTO $tableoptiongroups (group_id,  group_name, group_desc) VALUES(8, 'Link Manager Settings', 'Various settings for the link manager.')",
    621 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,60,1 )",
    622 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,61,2 )",
    623 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,62,3 )",
    624 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,63,4 )",
    625 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,64,5 )",
    626 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,65,6 )",
    627 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,66,7 )",
    628 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,67,8 )",
    629 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,68,9 )",
    630 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,69,10)",
    631 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,70,11)",
    632 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,71,12)",
    633 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,72,13)",
    634 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,73,14)",
    635 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,74,15)",
    636 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,75,16)",
    637 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,76,17)",
    638 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,77,18)",
    639 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,78,19)",
    640 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,79,20)",
    641 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,80,21)",
    642 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,81,22)",
    643 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(8,82,23)",
     620"INSERT INTO $wpdb->optiongroups (group_id,  group_name, group_desc) VALUES(8, 'Link Manager Settings', 'Various settings for the link manager.')",
     621"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,60,1 )",
     622"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,61,2 )",
     623"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,62,3 )",
     624"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,63,4 )",
     625"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,64,5 )",
     626"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,65,6 )",
     627"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,66,7 )",
     628"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,67,8 )",
     629"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,68,9 )",
     630"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,69,10)",
     631"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,70,11)",
     632"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,71,12)",
     633"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,72,13)",
     634"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,73,14)",
     635"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,74,15)",
     636"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,75,16)",
     637"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,76,17)",
     638"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,77,18)",
     639"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,78,19)",
     640"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,79,20)",
     641"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,80,21)",
     642"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,81,22)",
     643"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(8,82,23)",
    644644
    645645// select data for rating_type
    646 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number',    null,null,1)",
    647 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char',   'Character', null,null,2)",
    648 "INSERT INTO $tableoptionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image',  'Image',     null,null,3)",
     646"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'number', 'Number',    null,null,1)",
     647"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'char',   'Character', null,null,2)",
     648"INSERT INTO $wpdb->optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (62, 'image',  'Image',     null,null,3)",
    649649);
    650650
    … …  
    659659$geo_option_data = array(
    660660// data for geo settings
    661 "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)",
    662 "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)",
    663 "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)",
    664 "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)",
    665 
    666 "INSERT INTO $tableoptiongroups (group_id, group_name, group_desc) VALUES(9,'Geo Options', 'Settings which control the posting and display of Geo Options')",
    667 
    668 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(9,84,1)",
    669 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(9,85,1)",
    670 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(9,86,1)",
    671 "INSERT INTO $tableoptiongroup_options (group_id, option_id, seq) VALUES(9,87,1)",
     661"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)",
     662"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)",
     663"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)",
     664"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)",
     665
     666"INSERT INTO $wpdb->optiongroups (group_id, group_name, group_desc) VALUES(9,'Geo Options', 'Settings which control the posting and display of Geo Options')",
     667
     668"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(9,84,1)",
     669"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(9,85,1)",
     670"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(9,86,1)",
     671"INSERT INTO $wpdb->optiongroup_options (group_id, option_id, seq) VALUES(9,87,1)",
    672672
    673673);
    … …  
    705705$url = $_REQUEST['url'];
    706706if (isset($url)) {
    707     $query= "UPDATE $tableoptions set option_value='$url' where option_id=1"; //siteurl
     707    $query= "UPDATE $wpdb->options set option_value='$url' where option_id=1"; //siteurl
    708708    $q = $wpdb->query($query);
    709709}
    710710
    711 // $query = "DROP TABLE IF EXISTS $tableusers";
    712 // $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$tableusers\" in the database.");
    713 
    714 $query = "
    715 CREATE TABLE $tableusers (
     711// $query = "DROP TABLE IF EXISTS $wpdb->users";
     712// $q = mysql_query($query) or mysql_doh("doh, can't drop the table \"$wpdb->users\" in the database.");
     713
     714$query = "
     715CREATE TABLE $wpdb->users (
    716716  ID int(10) unsigned NOT NULL auto_increment,
    717717  user_login varchar(20) NOT NULL default '',
    … …  
    740740$random_password = substr(md5(uniqid(microtime())),0,6);
    741741
    742 $query = "INSERT INTO $tableusers (ID, user_login, user_pass, user_firstname, user_lastname, user_nickname, user_icq, user_email, user_url, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_aim, user_msn, user_yim, user_idmode) VALUES ( '1', 'admin', MD5('$random_password'), '', '', 'site admin', '0', '$admin_email', '', '127.0.0.1', '127.0.0.1', '', '00-00-0000 00:00:01', '10', '', '', '', 'nickname')";
     742$query = "INSERT INTO $wpdb->users (ID, user_login, user_pass, user_firstname, user_lastname, user_nickname, user_icq, user_email, user_url, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_aim, user_msn, user_yim, user_idmode) VALUES ( '1', 'admin', MD5('$random_password'), '', '', 'site admin', '0', '$admin_email', '', '127.0.0.1', '127.0.0.1', '', '00-00-0000 00:00:01', '10', '', '', '', 'nickname')";
    743743$q = $wpdb->query($query);
    744744
  • trunk/wp-admin/link-add.php

    r1200 r1355  
    77
    88function category_dropdown($fieldname, $selected = 0) {
    9     global $wpdb, $tablelinkcategories;
    10 
    11     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     9    global $wpdb;
     10
     11    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    1212    echo '        <select name="'.$fieldname.'" size="1">'."\n";
    1313    foreach ($results as $row) {
  • trunk/wp-admin/link-categories.php

    r1175 r1355  
    7272          $list_limit = -1;
    7373
    74       $wpdb->query("INSERT INTO $tablelinkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" .
     74      $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" .
    7575             " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" .
    7676             " VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" .
    … …  
    9696      die (__("Cheatin' uh ?"));
    9797
    98     $wpdb->query("DELETE FROM $tablelinkcategories WHERE cat_id='$cat_id'");
    99     $wpdb->query("UPDATE $tablelinks SET link_category=1 WHERE link_category='$cat_id'");
     98    $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'");
     99    $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'");
    100100
    101101    header('Location: link-categories.php');
    … …  
    108108    $row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    109109         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    110          . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_id=$cat_id");
     110         . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$cat_id");
    111111    if ($row) {
    112112        if ($row->list_limit == -1) {
    … …  
    264264        $list_limit = -1;
    265265
    266     $wpdb->query("UPDATE $tablelinkcategories set
     266    $wpdb->query("UPDATE $wpdb->linkcategories set
    267267            cat_name='$cat_name',
    268268            auto_toggle='$auto_toggle',
    … …  
    325325$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    326326         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    327          . " text_after_all, list_limit FROM $tablelinkcategories ORDER BY cat_id");
     327         . " text_after_all, list_limit FROM $wpdb->linkcategories ORDER BY cat_id");
    328328$i = 1;
    329329foreach ($results as $row) {
  • trunk/wp-admin/link-import.php

    r1182 r1355  
    5959        <?php _e('Category:') ?> <?php echo gethelp_link($this_file,'link_category');?><select name="cat_id">
    6060<?php
    61         $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     61        $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    6262        foreach ($categories as $category) {
    6363?>
    … …  
    123123                        if ('http' == substr($titles[$i], 0, 4))
    124124                            $titles[$i] = '';
    125                         $query = "INSERT INTO $tablelinks (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
     125                        $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
    126126                                VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '', $cat_id, '".addslashes($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
    127127                        $result = $wpdb->query($query);
  • trunk/wp-admin/link-manager.php

    r1352 r1355  
    2121
    2222function category_dropdown($fieldname, $selected = 0) {
    23         global $wpdb, $tablelinkcategories;
     23        global $wpdb;
    2424       
    25         $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     25        $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    2626        echo "\n<select name='$fieldname' size='1'>";
    2727        foreach ($results as $row) {
    … …  
    100100    }
    101101    $all_links = join(',', $linkcheck);
    102     $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM $tablelinks LEFT JOIN $tableusers ON link_owner = ID WHERE link_id in ($all_links)");
     102    $results = $wpdb->get_results("SELECT link_id, link_owner, user_level FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
    103103    foreach ($results as $row) {
    104104      if (!get_settings('links_use_adminlevels') || ($user_level >= $row->user_level)) { // ok to proceed
    … …  
    109109    // should now have an array of links we can change
    110110    $all_links = join(',', $ids_to_change);
    111     $q = $wpdb->query("update $tablelinks SET link_owner='$newowner' WHERE link_id IN ($all_links)");
     111    $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
    112112
    113113    header('Location: ' . $this_file);
    … …  
    131131    }
    132132    $all_links = join(',', $linkcheck);
    133     $results = $wpdb->get_results("SELECT link_id, link_visible FROM $tablelinks WHERE link_id in ($all_links)");
     133    $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
    134134    foreach ($results as $row) {
    135135        if ($row->link_visible == 'Y') { // ok to proceed
    … …  
    143143    if (count($ids_to_turnoff)) {
    144144        $all_linksoff = join(',', $ids_to_turnoff);
    145         $q = $wpdb->query("update $tablelinks SET link_visible='N' WHERE link_id IN ($all_linksoff)");
     145        $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
    146146    }
    147147
    148148    if (count($ids_to_turnon)) {
    149149        $all_linkson = join(',', $ids_to_turnon);
    150         $q = $wpdb->query("update $tablelinks SET link_visible='Y' WHERE link_id IN ($all_linkson)");
     150        $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
    151151    }
    152152
    … …  
    172172    $all_links = join(',', $linkcheck);
    173173    // should now have an array of links we can change
    174     $q = $wpdb->query("update $tablelinks SET link_category='$category' WHERE link_id IN ($all_links)");
     174    $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
    175175
    176176    header('Location: ' . $this_file);
    … …  
    204204    // need to make the others invisible before we add this new one.
    205205    if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    206       $wpdb->query("UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category");
    207     }
    208     $wpdb->query("INSERT INTO $tablelinks (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) " .
     206      $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
     207    }
     208    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) " .
    209209      " VALUES('" . addslashes($link_url) . "','"
    210210           . addslashes($link_name) . "', '"
    … …  
    254254      // need to make the others invisible before we update this one.
    255255      if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    256         $wpdb->query("UPDATE $tablelinks set link_visible = 'N' WHERE link_category = $link_category");
     256        $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
    257257      }
    258258
    259       $wpdb->query("UPDATE $tablelinks SET link_url='" . addslashes($link_url) . "',
     259      $wpdb->query("UPDATE $wpdb->links SET link_url='" . addslashes($link_url) . "',
    260260          link_name='" . addslashes($link_name) . "',\n link_image='" . addslashes($link_image) . "',
    261261          link_target='$link_target',\n link_category=$link_category,
    … …  
    284284      die (__("Cheatin' uh ?"));
    285285
    286     $wpdb->query("DELETE FROM $tablelinks WHERE link_id = $link_id");
     286    $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = $link_id");
    287287
    288288    if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    … …  
    309309
    310310    $row = $wpdb->get_row("SELECT *
    311         FROM $tablelinks
     311        FROM $wpdb->links
    312312        WHERE link_id = $link_id");
    313313
    … …  
    618618        <td>
    619619<?php
    620     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
     620    $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    621621    echo "        <select name=\"cat_id\">\n";
    622622    echo "          <option value=\"All\"";
    … …  
    676676<?php
    677677    $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
    678             link_category AS cat_id, cat_name AS category, $tableusers.user_login, link_id,
    679             link_rating, link_rel, $tableusers.user_level
    680             FROM $tablelinks
    681             LEFT JOIN $tablelinkcategories ON $tablelinks.link_category = $tablelinkcategories.cat_id
    682             LEFT JOIN $tableusers ON $tableusers.ID = $tablelinks.link_owner ";
     678            link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
     679            link_rating, link_rel, $wpdb->users.user_level
     680            FROM $wpdb->links
     681            LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
     682            LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
    683683
    684684    if (isset($cat_id) && ($cat_id != 'All')) {
    … …  
    748748          <?php _e('Assign ownership to:'); echo ' ' . gethelp_link($this_file,'assign_ownership'); ?>
    749749<?php
    750     $results = $wpdb->get_results("SELECT ID, user_login FROM $tableusers WHERE user_level > 0 ORDER BY ID");
     750    $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
    751751    echo "          <select name=\"newowner\" size=\"1\">\n";
    752752    foreach ($results as $row) {
  • trunk/wp-admin/moderation.php

    r1239 r1355  
    135135<div class="wrap">
    136136<?php
    137 $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_approved = '0'");
     137$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0'");
    138138
    139139if ($comments) {
    … …  
    148148    foreach($comments as $comment) {
    149149        $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
    150         $post_title = $wpdb->get_var("SELECT post_title FROM $tableposts WHERE ID='$comment->comment_post_ID'");
     150        $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
    151151       
    152152        echo "\n\t<li id='comment-$comment->comment_ID'>";
  • trunk/wp-admin/optionhandler.php

    r700 r1355  
    1010function get_option_widget($option_result, $editable, $between)
    1111{
    12     global $wpdb, $tableoptionvalues;
     12    global $wpdb;
    1313    $disabled = $editable ? '' : 'disabled';
    1414
    … …  
    4848
    4949            $select = $wpdb->get_results("SELECT optionvalue, optionvalue_desc "
    50                                          ."FROM $tableoptionvalues "
     50                                         ."FROM $wpdb->optionvalues "
    5151                                         ."WHERE option_id = $option_result->option_id "
    5252                                         ."ORDER BY optionvalue_seq");
    … …  
    6767        case 7: // SQL select
    6868            // first get the sql to run
    69             $sql = $wpdb->get_var("SELECT optionvalue FROM $tableoptionvalues WHERE option_id = $option_result->option_id");
     69            $sql = $wpdb->get_var("SELECT optionvalue FROM $wpdb->optionvalues WHERE option_id = $option_result->option_id");
    7070            if (!$sql) {
    7171                return $option_result->option_name . $editable;
    … …  
    101101
    102102function validate_option($option, $name, $val) {
    103     global $wpdb, $tableoptionvalues;
     103    global $wpdb;
    104104    $msg = '';
    105105    switch ($option->option_type) {
    106106        case 6: // range
    107107            // get range
    108             $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $tableoptionvalues WHERE option_id = $option->option_id");
     108            $range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $wpdb->optionvalues WHERE option_id = $option->option_id");
    109109            if ($range) {
    110110                if (($val < $range->optionvalue_min) || ($val > $range->optionvalue_max)) {
  • trunk/wp-admin/options-head.php

    r1272 r1355  
    77//we need to iterate through the available option groups.
    88$groups = '';
    9 $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");
     9$option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $wpdb->optiongroups ORDER BY group_id");
    1010foreach ($option_groups as $option_group) {
    1111        if ($option_group->group_id == $option_group_id) {
  • trunk/wp-admin/options-writing.php

    r1240 r1355  
    108108                        <td><select name="default_category" id="default_category">
    109109<?php
    110 $categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
     110$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    111111foreach ($categories as $category) :
    112112if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
  • trunk/wp-admin/options.php

    r1273 r1355  
    6464        }
    6565
    66     $options = $wpdb->get_results("SELECT $tableoptions.option_id, option_name, option_type, option_value, option_admin_level FROM $tableoptions WHERE option_name IN ($option_names)");
     66    $options = $wpdb->get_results("SELECT $wpdb->options.option_id, option_name, option_type, option_value, option_admin_level FROM $wpdb->options WHERE option_name IN ($option_names)");
    6767//      die(var_dump($options));
    6868
    … …  
    8484                                if( in_array($option->option_name, $nonbools) && $new_val == 0 ) $new_value = 'closed';
    8585                if ($new_val !== $old_val) {
    86                                         $query = "UPDATE $tableoptions SET option_value = '$new_val' WHERE option_name = '$option->option_name'";
     86                                        $query = "UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'";
    8787                                        $result = $wpdb->query($query);
    8888                                        //if( in_array($option->option_name, $nonbools)) die('boo'.$query);
    … …  
    131131<?php
    132132    //iterate through the available option groups. output them as a definition list.
    133     $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");
     133    $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $wpdb->optiongroups ORDER BY group_id");
    134134    foreach ($option_groups as $option_group) {
    135135        echo("  <dt><a href=\"$this_file?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></dt>\n");
    … …  
    160160//Now display all the options for the selected group.
    161161if ('all' == $_GET['option_group_id']) :
    162 $options = $wpdb->get_results("SELECT * FROM $tableoptions LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id ORDER BY option_name");
     162$options = $wpdb->get_results("SELECT * FROM $wpdb->options LEFT JOIN $wpdb->optiongroup_options ON $wpdb->options.option_id = $wpdb->optiongroup_options.option_id ORDER BY option_name");
    163163else :
    164164$options = $wpdb->get_results("
    165165SELECT
    166 $tableoptions.option_id, option_name, option_type, option_value, option_width, option_height, option_description, option_admin_level
    167 FROM $tableoptions  LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id
     166$wpdb->options.option_id, option_name, option_type, option_value, option_width, option_height, option_description, option_admin_level
     167FROM $wpdb->options  LEFT JOIN $wpdb->optiongroup_options ON $wpdb->options.option_id = $wpdb->optiongroup_options.option_id
    168168WHERE group_id = $option_group_id
    169169ORDER BY seq
  • trunk/wp-admin/post.php

    r1352 r1355  
    109109
    110110        if((get_settings('use_geo_positions')) && (strlen($latstr) > 2) && (strlen($lonstr) > 2) ) {
    111         $postquery ="INSERT INTO $tableposts
     111        $postquery ="INSERT INTO $wpdb->posts
    112112                        (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_lat, post_lon, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt)
    113113                        VALUES
    … …  
    115115                        ";
    116116        } else {
    117         $postquery ="INSERT INTO $tableposts
     117        $postquery ="INSERT INTO $wpdb->posts
    118118                        (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt)
    119119                        VALUES
    … …  
    124124        $result = $wpdb->query($postquery);
    125125
    126         $post_ID = $wpdb->get_var("SELECT ID FROM $tableposts ORDER BY ID DESC LIMIT 1");
     126        $post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1");
    127127
    128128        if (!empty($_POST['mode'])) {
    … …  
    152152        foreach ($post_categories as $post_category) {
    153153                // Double check it's not there already
    154                 $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category");
     154                $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category");
    155155
    156156                 if (!$exists && $result) {
    157157                        $wpdb->query("
    158                         INSERT INTO $tablepost2cat
     158                        INSERT INTO $wpdb->post2cat
    159159                        (post_id, category_id)
    160160                        VALUES
    … …  
    182182
    183183                // Time for trackbacks
    184                 $to_ping = $wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID");
    185                 $pinged = $wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID");
     184                $to_ping = $wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_ID");
     185                $pinged = $wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_ID");
    186186                $pinged = explode("\n", $pinged);
    187187                if ('' != $to_ping) {
    … …  
    214214        $post = $post_ID = $p = (int) $_GET['post'];
    215215        if ($user_level > 0) {
    216                 $postdata = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = '$post_ID'");
     216                $postdata = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
    217217                $authordata = get_userdata($postdata->post_author);
    218218                if ($user_level < $authordata->user_level)
    … …  
    236236                include('edit-form-advanced.php');
    237237
    238                 $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = '$post_ID'");
     238                $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
    239239                ?>
    240240<div id='preview' class='wrap'>
    … …  
    344344
    345345        $result = $wpdb->query("
    346                 UPDATE $tableposts SET
     346                UPDATE $wpdb->posts SET
    347347                        post_content = '$content',
    348348                        post_excerpt = '$excerpt',
    … …  
    365365        // Now it's category time!
    366366        // First the old categories
    367         $old_categories = $wpdb->get_col("SELECT category_id FROM $tablepost2cat WHERE post_id = $post_ID");
     367        $old_categories = $wpdb->get_col("SELECT category_id FROM $wpdb->post2cat WHERE post_id = $post_ID");
    368368       
    369369        // Delete any?
    370370        foreach ($old_categories as $old_cat) {
    371371                if (!in_array($old_cat, $post_categories)) // If a category was there before but isn't now
    372                         $wpdb->query("DELETE FROM $tablepost2cat WHERE category_id = $old_cat AND post_id = $post_ID LIMIT 1");
     372                        $wpdb->query("DELETE FROM $wpdb->post2cat WHERE category_id = $old_cat AND post_id = $post_ID LIMIT 1");
    373373        }
    374374       
    … …  
    376376        foreach ($post_categories as $new_cat) {
    377377                if (!in_array($new_cat, $old_categories))
    378                         $wpdb->query("INSERT INTO $tablepost2cat (post_id, category_id) VALUES ($post_ID, $new_cat)");
     378                        $wpdb->query("INSERT INTO $wpdb->post2cat (post_id, category_id) VALUES ($post_ID, $new_cat)");
    379379        }
    380380       
    … …  
    393393                do_action('publish_post', $post_ID);
    394394                // Trackback time.
    395                 $to_ping = trim($wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID"));
    396                 $pinged = trim($wpdb->get_var("SELECT pinged FROM $tableposts WHERE ID = $post_ID"));
     395                $to_ping = trim($wpdb->get_var("SELECT to_ping FROM $wpdb->posts WHERE ID = $post_ID"));
     396                $pinged = trim($wpdb->get_var("SELECT pinged FROM $wpdb->posts WHERE ID = $post_ID"));
    397397                $pinged = explode("\n", $pinged);
    398398                if ('' != $to_ping) {
    … …  
    450450
    451451        // send geoURL ping to "erase" from their DB
    452         $query = "SELECT post_lat from $tableposts WHERE ID=$post_id";
     452        $query = "SELECT post_lat from $wpdb->posts WHERE ID=$post_id";
    453453        $rows = $wpdb->query($query);
    454454        $myrow = $rows[0];
    … …  
    458458        }
    459459
    460         $result = $wpdb->query("DELETE FROM $tableposts WHERE ID=$post_id");
     460        $result = $wpdb->query("DELETE FROM $wpdb->posts WHERE ID=$post_id");
    461461        if (!$result)
    462462                die(__('Error in deleting...'));
    463463
    464         $result = $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID=$post_id");
    465 
    466         $categories = $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id = $post_id");
     464        $result = $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID=$post_id");
     465
     466        $categories = $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $post_id");
    467467
    468468        if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
    … …  
    695695
    696696        $result = $wpdb->query("
    697                 UPDATE $tablecomments SET
     697                UPDATE $wpdb->comments SET
    698698                        comment_content = '$content',
    699699                        comment_author = '$newcomment_author',
    … …  
    717717                $action = 'post';
    718718                get_currentuserinfo();
    719                 $drafts = $wpdb->get_results("SELECT ID, post_title FROM $tableposts WHERE post_status = 'draft' AND post_author = $user_ID");
     719                $drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_ID");
    720720                if ($drafts) {
    721721                        ?>
  • trunk/wp-admin/profile.php

    r1352 r1355  
    9696        $user_description = addslashes(stripslashes($_POST['user_description']));
    9797
    98         $query = "UPDATE $tableusers SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description' WHERE ID = $user_ID";
     98        $query = "UPDATE $wpdb->users SET user_firstname='$newuser_firstname', $updatepassword user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode', user_description = '$user_description' WHERE ID = $user_ID";
    9999        $result = $wpdb->query($query);
    100100        if (!$result) {
  • 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
  • trunk/wp-admin/users.php

    r1303 r1355  
    5656
    5757        /* checking the login isn't already used by another user */
    58         $loginthere = $wpdb->get_var("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
     58        $loginthere = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
    5959    if ($loginthere) {
    6060                die (__('<strong>ERROR</strong>: This login is already registered, please choose another one.'));
    … …  
    7979        $new_users_can_blog = get_settings('new_users_can_blog');
    8080
    81         $result = $wpdb->query("INSERT INTO $tableusers
     81        $result = $wpdb->query("INSERT INTO $wpdb->users
    8282                (user_login, user_pass, user_nickname, user_email, user_ip, user_domain, user_browser, dateYMDhour, user_level, user_idmode, user_firstname, user_lastname, user_nicename)
    8383        VALUES
    … …  
    123123        if ('up' == $prom) {
    124124                $new_level = $usertopromote_level + 1;
    125                 $sql="UPDATE $tableusers SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
     125                $sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
    126126        } elseif ('down' == $prom) {
    127127                $new_level = $usertopromote_level - 1;
    128                 $sql="UPDATE $tableusers SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
     128                $sql="UPDATE $wpdb->users SET user_level=$new_level WHERE ID = $id AND $new_level < $user_level";
    129129        }
    130130        $result = $wpdb->query($sql);
    … …  
    153153                die(__('Can&#8217;t delete a user whose level is higher than yours.'));
    154154
    155         $post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id");
     155        $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id");
    156156        if ($post_ids) {
    157157                $post_ids = implode(',', $post_ids);
    158158               
    159159                // Delete comments, *backs
    160                 $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
     160                $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID IN ($post_ids)");
    161161                // Clean cats
    162                 $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
     162                $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
    163163                // Clean post_meta
    164                 $wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
     164                $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id IN ($post_ids)");
    165165                // Clean links
    166                 $wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
     166                $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id");
    167167                // Delete posts
    168                 $wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
     168                $wpdb->query("DELETE FROM $wpdb->posts WHERE post_author = $id");
    169169        }
    170170
    171171        // FINALLY, delete user
    172         $wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
     172        $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
    173173        header('Location: users.php?deleted=true');
    174174
    … …  
    196196        </tr>
    197197        <?php
    198         $users = $wpdb->get_results("SELECT ID FROM $tableusers WHERE user_level > 0 ORDER BY ID");
     198        $users = $wpdb->get_results("SELECT ID FROM $wpdb->users WHERE user_level > 0 ORDER BY ID");
    199199        $style = '';
    200200        foreach ($users as $user) {
    … …  
    209209                $short_url =  substr($short_url, 0, 32).'...';
    210210                $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
    211                 $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = $user->ID and post_status = 'publish'");
     211                $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $user->ID and post_status = 'publish'");
    212212                if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_data->ID' title='" . __('View posts') . "'>$numposts</a>";
    213213                echo "
    … …  
    234234
    235235<?php
    236         $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level = 0 ORDER BY ID");
     236        $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level = 0 ORDER BY ID");
    237237        if ($users) {
    238238?>
  • trunk/wp-blog-header.php

    r1354 r1355  
    167167    }
    168168}
     169
    169170?>
  • trunk/wp-comments-popup.php

    r1108 r1355  
    3535$comment_author_email = (isset($_COOKIE['comment_author_email_'.$cookiehash])) ? trim($_COOKIE['comment_author_email_'.$cookiehash]) : '';
    3636$comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : '';
    37 $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
    38 $commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $tableposts WHERE ID = $id");
     37$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1' ORDER BY comment_date");
     38$commentstatus = $wpdb->get_row("SELECT comment_status, post_password FROM $wpdb->posts WHERE ID = $id");
    3939if (!empty($commentstatus->post_password) && $_COOKIE['wp-postpass_'.$cookiehash] != $commentstatus->post_password) {  // and it doesn't match the cookie
    4040        echo(get_the_password_form());
  • trunk/wp-comments-post.php

    r1237 r1355  
    3333$user_ip = $_SERVER['REMOTE_ADDR'];
    3434
    35 if ( 'closed' ==  $wpdb->get_var("SELECT comment_status FROM $tableposts WHERE ID = '$comment_post_ID'") )
     35if ( 'closed' ==  $wpdb->get_var("SELECT comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'") )
    3636        die( __('Sorry, comments are closed for this item.') );
    3737
    … …  
    5252
    5353// Simple flood-protection
    54 $lasttime = $wpdb->get_var("SELECT comment_date FROM $tablecomments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");
     54$lasttime = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_author_IP = '$user_ip' ORDER BY comment_date DESC LIMIT 1");
    5555if (!empty($lasttime)) {
    5656        $time_lastcomment= mysql2date('U', $lasttime);
    … …  
    6969}
    7070
    71 $wpdb->query("INSERT INTO $tablecomments
     71$wpdb->query("INSERT INTO $wpdb->comments
    7272(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved)
    7373VALUES
  • trunk/wp-comments-reply.php

    r1203 r1355  
    3535        $comment_author_email = (isset($_COOKIE['comment_author_email_'.$cookiehash])) ? trim($_COOKIE['comment_author_email_'.$cookiehash]) : '';
    3636                $comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : '';
    37         $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = '$id' AND comment_approved = '1' AND comment_ID = '$comment_reply_ID' ORDER BY comment_date");
     37        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$id' AND comment_approved = '1' AND comment_ID = '$comment_reply_ID' ORDER BY comment_date");
    3838?>
    3939
  • trunk/wp-comments.php

    r1311 r1355  
    1818                $comment_author_url = (isset($_COOKIE['comment_author_url_'.$cookiehash])) ? trim($_COOKIE['comment_author_url_'.$cookiehash]) : '';
    1919
    20         $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = '$id' AND comment_approved = '1' ORDER BY comment_date");
     20        $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$id' AND comment_approved = '1' ORDER BY comment_date");
    2121?>
    2222
  • trunk/wp-commentsrss2.php

    r1223 r1355  
    2929                        $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
    3030                        comment_author_url, comment_date, comment_content, comment_post_ID,
    31                         $tableposts.ID, $tableposts.post_password FROM $tablecomments
    32                         LEFT JOIN $tableposts ON comment_post_id = id WHERE comment_post_ID = '$id'
    33                         AND $tablecomments.comment_approved = '1' AND $tableposts.post_status = 'publish'
     31                        $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
     32                        LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
     33                        AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
    3434                        AND post_date < '".date("Y-m-d H:i:59")."'
    3535                        ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') );
    … …  
    3737                        $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
    3838                        comment_author_url, comment_date, comment_content, comment_post_ID,
    39                         $tableposts.ID, $tableposts.post_password FROM $tablecomments
    40                         LEFT JOIN $tableposts ON comment_post_id = id WHERE $tableposts.post_status = 'publish'
    41                         AND $tablecomments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' 
     39                        $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
     40                        LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
     41                        AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' 
    4242                        ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
    4343                }
  • trunk/wp-includes/functions-post.php

    r1353 r1355  
    77 */
    88function wp_insert_post($postarr = array()) {
    9         global $wpdb, $tableposts, $post_default_category;
     9        global $wpdb, $post_default_category;
    1010       
    1111        // export array as variables
    … …  
    3232                $post_date_gmt = get_gmt_from_date($post_date);
    3333       
    34         $sql = "INSERT INTO $tableposts
     34        $sql = "INSERT INTO $wpdb->posts
    3535                (post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name)
    3636                VALUES ('$post_author', '$post_date', '$post_date_gmt', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_cat', '$post_status', '$post_name')";
    … …  
    5050
    5151function wp_get_single_post($postid = 0, $mode = OBJECT) {
    52         global $wpdb, $tableposts;
    53 
    54         $sql = "SELECT * FROM $tableposts WHERE ID=$postid";
     52        global $wpdb;
     53
     54        $sql = "SELECT * FROM $wpdb->posts WHERE ID=$postid";
    5555        $result = $wpdb->get_row($sql, $mode);
    5656       
    … …  
    6262
    6363function wp_get_recent_posts($num = 10) {
    64         global $wpdb, $tableposts;
     64        global $wpdb;
    6565
    6666        // Set the limit clause, if we got a limit
    … …  
    6969        }
    7070
    71         $sql = "SELECT * FROM $tableposts ORDER BY post_date DESC $limit";
     71        $sql = "SELECT * FROM $wpdb->posts ORDER BY post_date DESC $limit";
    7272        $result = $wpdb->get_results($sql,ARRAY_A);
    7373
    … …  
    7676
    7777function wp_update_post($postarr = array()) {
    78         global $wpdb, $tableposts;
     78        global $wpdb;
    7979
    8080        // First get all of the original fields
    … …  
    9797        $post_modified_gmt = current_time('mysql', 1);
    9898
    99         $sql = "UPDATE $tableposts
     99        $sql = "UPDATE $wpdb->posts
    100100                SET post_content = '$post_content',
    101101                post_title = '$post_title',
    … …  
    119119
    120120function wp_get_post_cats($blogid = '1', $post_ID = 0) {
    121         global $wpdb, $tablepost2cat;
     121        global $wpdb;
    122122       
    123123        $sql = "SELECT category_id
    124                 FROM $tablepost2cat
     124                FROM $wpdb->post2cat
    125125                WHERE post_id = $post_ID
    126126                ORDER BY category_id";
    … …  
    132132
    133133function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
    134         global $wpdb, $tablepost2cat;
     134        global $wpdb;
    135135        // If $post_categories isn't already an array, make it one:
    136136        if (!is_array($post_categories)) {
    … …  
    146146        $old_categories = $wpdb->get_col("
    147147                SELECT category_id
    148                 FROM $tablepost2cat
     148                FROM $wpdb->post2cat
    149149                WHERE post_id = $post_ID");
    150150       
    … …  
    169169                foreach ($delete_cats as $del) {
    170170                        $wpdb->query("
    171                                 DELETE FROM $tablepost2cat
     171                                DELETE FROM $wpdb->post2cat
    172172                                WHERE category_id = $del
    173173                                        AND post_id = $post_ID
    … …  
    186186                foreach ($add_cats as $new_cat) {
    187187                        $wpdb->query("
    188                                 INSERT INTO $tablepost2cat (post_id, category_id)
     188                                INSERT INTO $wpdb->post2cat (post_id, category_id)
    189189                                VALUES ($post_ID, $new_cat)");
    190190
    … …  
    195195
    196196function wp_delete_post($postid = 0) {
    197         global $wpdb, $tableposts, $tablepost2cat;
    198        
    199         $sql = "DELETE FROM $tablepost2cat WHERE post_id = $postid";
     197        global $wpdb;
     198       
     199        $sql = "DELETE FROM $wpdb->post2cat WHERE post_id = $postid";
    200200        $wpdb->query($sql);
    201201               
    202         $sql = "DELETE FROM $tableposts WHERE ID = $postid";
     202        $sql = "DELETE FROM $wpdb->posts WHERE ID = $postid";
    203203       
    204204        $wpdb->query($sql);
    … …  
    216216function post_permalink($post_ID=0, $mode = 'id') {
    217217    global $wpdb;
    218         global $tableposts;
    219218        global $querystring_start, $querystring_equal, $querystring_separator;
    220219
    … …  
    266265// Get the name of a category from its ID
    267266function get_cat_name($cat_id) {
    268         global $wpdb,$tablecategories;
     267        global $wpdb;
    269268       
    270269        $cat_id -= 0;   // force numeric
    271         $name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID=$cat_id");
     270        $name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id");
    272271       
    273272        return $name;
    … …  
    276275// Get the ID of a category from its name
    277276function get_cat_ID($cat_name='General') {
    278         global $wpdb,$tablecategories;
    279        
    280         $cid = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE cat_name='$cat_name'");
     277        global $wpdb;
     278       
     279        $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
    281280
    282281        return $cid?$cid:1;     // default to cat 1
  • trunk/wp-includes/functions.php

    r1354 r1355  
    9696
    9797function get_lastpostdate($timezone = 'server') {
    98         global $tableposts, $cache_lastpostdate, $pagenow, $wpdb;
     98        global $cache_lastpostdate, $pagenow, $wpdb;
    9999        $add_seconds_blog = get_settings('gmt_offset') * 3600;
    100100        $add_seconds_server = date('Z');
    … …  
    103103                switch(strtolower($timezone)) {
    104104                        case 'gmt':
    105                                 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     105                                $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    106106                                break;
    107107                        case 'blog':
    108                                 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     108                                $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    109109                                break;
    110110                        case 'server':
    111                                 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tableposts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     111                                $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    112112                                break;
    113113                }
    … …  
    120120
    121121function get_lastpostmodified($timezone = 'server') {
    122         global $tableposts, $cache_lastpostmodified, $pagenow, $wpdb;
     122        global $cache_lastpostmodified, $pagenow, $wpdb;
    123123        $add_seconds_blog = get_settings('gmt_offset') * 3600;
    124124        $add_seconds_server = date('Z');
    … …  
    127127                switch(strtolower($timezone)) {
    128128                        case 'gmt':
    129                                 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     129                                $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    130130                                break;
    131131                        case 'blog':
    132                                 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     132                                $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    133133                                break;
    134134                        case 'server':
    135                                 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $tableposts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     135                                $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    136136                                break;
    137137                }
    … …  
    173173
    174174function get_userdata($userid) {
    175         global $wpdb, $cache_userdata, $tableusers;
     175        global $wpdb, $cache_userdata;
    176176        if ( empty($cache_userdata[$userid]) ) {
    177                 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = '$userid'");
     177                $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = '$userid'");
    178178                $user->user_nickname = stripslashes($user->user_nickname);
    179179                $user->user_firstname = stripslashes($user->user_firstname);
    … …  
    188188
    189189function get_userdatabylogin($user_login) {
    190         global $tableusers, $cache_userdata, $wpdb;
     190        global $cache_userdata, $wpdb;
    191191        if ( empty($cache_userdata["$user_login"]) ) {
    192                 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE user_login = '$user_login'");
     192                $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'");
    193193                $cache_userdata["$user_login"] = $user;
    194194        } else {
    … …  
    199199
    200200function get_userid($user_login) {
    201         global $tableusers, $cache_userdata, $wpdb;
     201        global $cache_userdata, $wpdb;
    202202        if ( empty($cache_userdata["$user_login"]) ) {
    203                 $user_id = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_login = '$user_login'");
     203                $user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_login'");
    204204
    205205                $cache_userdata["$user_login"] = $user_id;
    … …  
    211211
    212212function get_usernumposts($userid) {
    213         global $tableposts, $tablecomments, $wpdb;
    214         return $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = '$userid'");
     213        global $wpdb;
     214        return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid'");
    215215}
    216216
    … …  
    218218// determine the post ID it represents.
    219219function url_to_postid($url = '') {
    220         global $wpdb, $tableposts;
     220        global $wpdb;
    221221
    222222        $siteurl = get_settings('home');
    … …  
    291291
    292292        // Run the query to get the post ID:
    293         $id = intval($wpdb->get_var("SELECT ID FROM $tableposts WHERE 1 = 1 " . $where));
     293        $id = intval($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE 1 = 1 " . $where));
    294294
    295295        return $id;
    … …  
    322322
    323323function get_alloptions() {
    324         global $tableoptions, $wpdb;
    325         $options = $wpdb->get_results("SELECT option_name, option_value FROM $tableoptions");
     324        global $wpdb;
     325        $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
    326326        if ($options) {
    327327                foreach ($options as $option) {
    … …  
    339339
    340340function update_option($option_name, $newvalue) {
    341         global $wpdb, $tableoptions, $cache_settings;
     341        global $wpdb, $cache_settings;
    342342        $newvalue = stripslashes($newvalue);
    343343        $newvalue = trim($newvalue); // I can't think of any situation we wouldn't want to trim
    344344        $newvalue = $wpdb->escape($newvalue);
    345         $wpdb->query("UPDATE $tableoptions SET option_value = '$newvalue' WHERE option_name = '$option_name'");
     345        $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
    346346        $cache_settings = get_alloptions(); // Re cache settings
    347347        return true;
    … …  
    352352function add_option($name, $value='') {
    353353        // Adds an option if it doesn't already exist
    354         global $wpdb, $tableoptions;
     354        global $wpdb;
    355355        if(!get_settings($name)) {
    356356                $name = $wpdb->escape($name);
    357357                $value = $wpdb->escape($value);
    358                 $wpdb->query("INSERT INTO $tableoptions (option_name, option_value) VALUES ('$name', '$value')");
     358                $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value) VALUES ('$name', '$value')");
    359359
    360360                if($wpdb->insert_id) {
    … …  
    367367
    368368function delete_option($name) {
    369         global $wpdb, $tableoptions, $tableoptiongroup_options;
     369        global $wpdb;
    370370        // Get the ID, if no ID then return
    371         $option_id = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = '$name'");
     371        $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
    372372        if (!$option_id) return false;
    373         $wpdb->query("DELETE FROM $tableoptiongroup_options WHERE option_id = '$option_id'");
    374         $wpdb->query("DELETE FROM $tableoptions WHERE option_name = '$name'");
     373        $wpdb->query("DELETE FROM $wpdb->optiongroup_options WHERE option_id = '$option_id'");
     374        $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
    375375        return true;
    376376}
    377377
    378378function get_postdata($postid) {
    379         global $post, $tableposts, $wpdb;
    380 
    381         $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = '$postid'");
     379        global $post, $wpdb;
     380
     381        $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid'");
    382382       
    383383        $postdata = array (
    … …  
    403403
    404404function get_commentdata($comment_ID,$no_cache=0,$include_unapproved=false) { // less flexible, but saves DB queries
    405         global $postc,$id,$commentdata,$tablecomments, $wpdb;
     405        global $postc,$id,$commentdata, $wpdb;
    406406        if ($no_cache) {
    407                 $query = "SELECT * FROM $tablecomments WHERE comment_ID = '$comment_ID'";
     407                $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
    408408                if (false == $include_unapproved) {
    409409                    $query .= " AND comment_approved = '1'";
    … …  
    432432
    433433function get_catname($cat_ID) {
    434         global $tablecategories, $cache_catnames, $wpdb;
     434        global $cache_catnames, $wpdb;
    435435        if ( !$cache_catnames ) {
    436         $results = $wpdb->get_results("SELECT * FROM $tablecategories") or die('Oops, couldn\'t query the db for categories.');
     436        $results = $wpdb->get_results("SELECT * FROM $wpdb->categories") or die('Oops, couldn\'t query the db for categories.');
    437437                foreach ($results as $post) {
    438438                        $cache_catnames[$post->cat_ID] = $post->cat_name;
    … …  
    545545// Send a Trackback
    546546function trackback($trackback_url, $title, $excerpt, $ID) {
    547         global $wpdb, $tableposts;
     547        global $wpdb;
    548548        $title = urlencode(stripslashes($title));
    549549        $excerpt = urlencode(stripslashes($excerpt));
    … …  
    573573        @fclose($fs);
    574574
    575         $wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
    576         $wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
     575        $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
     576        $wpdb->query("UPDATE $wpdb->posts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
    577577        return $result;
    578578}
    … …  
    899899 */
    900900function wp_set_comment_status($comment_id, $comment_status) {
    901     global $wpdb, $tablecomments;
     901    global $wpdb;
    902902
    903903    switch($comment_status) {
    904904                case 'hold':
    905                         $query = "UPDATE $tablecomments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
     905                        $query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
    906906                break;
    907907                case 'approve':
    908                         $query = "UPDATE $tablecomments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
     908                        $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
    909909                break;
    910910                case 'delete':
    911                         $query = "DELETE FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1";
     911                        $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
    912912                break;
    913913                default:
    … …  
    935935 */
    936936function wp_get_comment_status($comment_id) {
    937     global $wpdb, $tablecomments;
     937    global $wpdb;
    938938   
    939     $result = $wpdb->get_var("SELECT comment_approved FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
     939    $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
    940940    if ($result == NULL) {
    941941        return "deleted";
    … …  
    950950
    951951function wp_notify_postauthor($comment_id, $comment_type='comment') {
    952     global $wpdb, $tablecomments, $tableposts, $tableusers;
     952    global $wpdb;
    953953    global $querystring_start, $querystring_equal, $querystring_separator;
    954954   
    955     $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
    956     $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
    957     $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
     955    $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
     956    $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
     957    $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
    958958
    959959    if ('' == $user->user_email) return false; // If there's no email to send the comment to
    … …  
    10101010 */
    10111011function wp_notify_moderator($comment_id) {
    1012     global $wpdb, $tablecomments, $tableposts, $tableusers;
     1012    global $wpdb;
    10131013    global $querystring_start, $querystring_equal, $querystring_separator;
    10141014   
    1015     $comment = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID='$comment_id' LIMIT 1");
    1016     $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID='$comment->comment_post_ID' LIMIT 1");
    1017     $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID='$post->post_author' LIMIT 1");
     1015    $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
     1016    $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
     1017    $user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID='$post->post_author' LIMIT 1");
    10181018
    10191019    $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
    1020     $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $tablecomments WHERE comment_approved = '0'");
     1020    $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
    10211021
    10221022    $notify_message  = "A new comment on the post #$comment->comment_post_ID \"".stripslashes($post->post_title)."\" is waiting for your approval\r\n\r\n";
    … …  
    13171317
    13181318function get_posts($args) {
    1319         global $wpdb, $tableposts;
     1319        global $wpdb;
    13201320        parse_str($args, $r);
    13211321        if (!isset($r['numberposts'])) $r['numberposts'] = 5;
    … …  
    13281328        $now = current_time('mysql');
    13291329
    1330         $posts = $wpdb->get_results("SELECT DISTINCT * FROM $tableposts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $tableposts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
     1330        $posts = $wpdb->get_results("SELECT DISTINCT * FROM $wpdb->posts WHERE post_date <= '$now' AND (post_status = 'publish') GROUP BY $wpdb->posts.ID ORDER BY post_date DESC LIMIT " . $r['offset'] . ',' . $r['numberposts']);
    13311331       
    13321332        return $posts;
    … …  
    13551355
    13561356function query_posts($query) {
    1357     global $wpdb, $tablepost2cat, $tableposts, $tablecategories, $tableusers,
     1357    global $wpdb,
    13581358        $pagenow;
    13591359
    … …  
    14861486            $andor = 'OR';
    14871487        }
    1488         $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
     1488        $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
    14891489        $cat_array = explode(' ',$cat);
    14901490        $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
    … …  
    15121512        }
    15131513        $category_name = preg_replace('|[^a-z0-9-_]|i', '', $category_name);
    1514         $tables = ", $tablepost2cat, $tablecategories";
    1515         $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
     1514        $tables = ", $wpdb->post2cat, $wpdb->categories";
     1515        $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
    15161516        $whichcat = " AND (category_nicename = '$category_name'";
    1517         $cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'");
     1517        $cat = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_name'");
    15181518        $whichcat .= get_category_children($cat, " OR category_id = ");
    15191519        $whichcat .= ")";
    … …  
    15561556        }
    15571557        $author_name = preg_replace('|[^a-z0-9-_]|', '', strtolower($author_name));
    1558         $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
     1558        $author = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$author_name."'");
    15591559        $whichauthor .= ' AND (post_author = '.intval($author).')';
    15601560    }
    … …  
    16631663    else
    16641664        $where .= ')';
    1665     $where .= " GROUP BY $tableposts.ID";
    1666     $request = " SELECT $distinct * FROM $tableposts $join WHERE 1=1".$where." ORDER BY post_$orderby $limits";
     1665    $where .= " GROUP BY $wpdb->posts.ID";
     1666    $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY post_$orderby $limits";
    16671667
    16681668
    … …  
    16831683function update_post_caches($posts) {
    16841684    global $category_cache, $comment_count_cache, $post_meta_cache;
    1685     global $tablecategories, $tablepost2cat, $tableposts, $tablecomments,
    1686         $tablepostmeta, $wpdb;
     1685    global $wpdb;
    16871686
    16881687    // No point in doing all this work if we didn't match any posts.
    … …  
    16991698    $dogs = $wpdb->get_results("SELECT DISTINCT
    17001699        ID, category_id, cat_name, category_nicename, category_description, category_parent
    1701         FROM $tablecategories, $tablepost2cat, $tableposts
     1700        FROM $wpdb->categories, $wpdb->post2cat, $wpdb->posts
    17021701        WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
    17031702       
    … …  
    17081707    // Do the same for comment numbers
    17091708    $comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
    1710         FROM $tableposts
    1711         LEFT JOIN $tablecomments ON ( comment_post_ID = ID  AND comment_approved =  '1')
     1709        FROM $wpdb->posts
     1710        LEFT JOIN $wpdb->comments ON ( comment_post_ID = ID  AND comment_approved =  '1')
    17121711        WHERE post_status =  'publish' AND ID IN ($post_id_list)
    17131712        GROUP BY ID");
    … …  
    17221721    if ( $meta_list = $wpdb->get_results("
    17231722                        SELECT post_id,meta_key,meta_value
    1724                         FROM $tablepostmeta
     1723                        FROM $wpdb->postmeta
    17251724                        WHERE post_id IN($post_id_list)
    17261725                        ORDER BY post_id,meta_key
    … …  
    17471746
    17481747function update_category_cache() {
    1749     global $cache_categories, $tablecategories, $wpdb;
    1750     $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
     1748    global $cache_categories, $wpdb;
     1749    $dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE 1=1");
    17511750    foreach ($dogs as $catt) {
    17521751        $cache_categories[$catt->cat_ID] = $catt;
    … …  
    17551754
    17561755function update_user_cache() {
    1757     global $cache_userdata, $tableusers, $wpdb;
    1758 
    1759     $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0");
     1756    global $cache_userdata, $wpdb;
     1757
     1758    $users = $wpdb->get_results("SELECT * FROM $wpdb->users WHERE user_level > 0");
    17601759    foreach ($users as $user) {
    17611760        $cache_userdata[$user->ID] = $user;
  • trunk/wp-includes/links-update-xml.php

    r1225 r1355  
    2020 **/
    2121function preload_links() {
    22         global $tablelinks, $all_links, $wpdb;
    23         $links = $wpdb->get_results("SELECT link_id, link_url FROM $tablelinks WHERE link_visible = 'Y' AND link_url <> ''");
     22        global $all_links, $wpdb;
     23        $links = $wpdb->get_results("SELECT link_id, link_url FROM $wpdb->links WHERE link_visible = 'Y' AND link_url <> ''");
    2424        foreach ($links as $link) {
    2525                $link_url = transform_url($link->link_url);
    … …  
    3333 **/
    3434function update_links() {
    35         global $tablelinks, $all_links, $wpdb;
     35        global $all_links, $wpdb;
    3636        reset($all_links);
    3737        while (list($id, $val) = each($all_links)) {
    3838                if ($val[1]) {
    39                         $wpdb->query("UPDATE $tablelinks SET link_updated = '$val[1]' WHERE link_id = $val[0]");
     39                        $wpdb->query("UPDATE $wpdb->links SET link_updated = '$val[1]' WHERE link_id = $val[0]");
    4040                }
    4141        } // end while
  • trunk/wp-includes/links.php

    r1258 r1355  
    2727                         $show_description = true, $show_rating = false,
    2828                         $limit = -1, $show_updated = 0) {
    29     global $tablelinkcategories, $wpdb;
     29    global $wpdb;
    3030    $cat_id = -1;
    31     $results = $wpdb->get_results("SELECT cat_id FROM $tablelinkcategories WHERE cat_name='$cat_name'");
     31    $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
    3232    if ($results) {
    3333        foreach ($results as $result) {
    … …  
    5050 **/
    5151function wp_get_linksbyname($category) {
    52     global $wpdb, $tablelinkcategories;
     52    global $wpdb;
    5353
    5454    $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    5555         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    56          . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_name='$category'");
     56         . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
    5757    if ($cat) {
    5858        if ($cat->sort_desc == 'Y') {
    … …  
    7272 **/
    7373function wp_get_links($category) {
    74     global $wpdb, $tablelinkcategories;
     74    global $wpdb;
    7575
    7676    $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    7777         . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    78          . " text_after_all, list_limit FROM $tablelinkcategories WHERE cat_id=$category");
     78         . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
    7979    if ($cat) {
    8080        if ($cat->sort_desc == 'Y') {
    … …  
    115115                   $limit = -1, $show_updated = 1, $echo = true) {
    116116
    117     global $tablelinks, $wpdb;
     117    global $wpdb;
    118118
    119119    $direction = ' ASC';
    … …  
    156156    $sql = "SELECT link_url, link_name, link_image, link_target,
    157157            link_description, link_rating, link_rel $length $recently_updated_test $get_updated
    158             FROM $tablelinks
     158            FROM $wpdb->links
    159159            WHERE link_visible = 'Y' " .
    160160           $category_query;
    … …  
    278278 **/
    279279function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
    280     global $tablelinkcategories, $wpdb;
     280    global $wpdb;
    281281    $cat_id = -1;
    282     $results = $wpdb->get_results("SELECT cat_id FROM $tablelinkcategories WHERE cat_name='$cat_name'");
     282    $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
    283283    if ($results) {
    284284        foreach ($results as $result) {
    … …  
    325325 **/
    326326function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
    327     global $tablelinks, $wpdb;
    328 
    329     $sql = "SELECT * FROM $tablelinks WHERE link_visible = 'Y'";
     327    global $wpdb;
     328
     329    $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
    330330    if ($category != -1) {
    331331        $sql .= " AND link_category = $category ";
    … …  
    460460 */
    461461function get_linkcatname($id = 0) {
    462     global $tablelinkcategories, $wpdb;
     462    global $wpdb;
    463463    $cat_name = '';
    464464    if ('' != $id) {
    465         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablelinkcategories WHERE cat_id=$id");
     465        $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
    466466    }
    467467    return stripslashes($cat_name);
    … …  
    474474 */
    475475function get_autotoggle($id = 0) {
    476     global $tablelinkcategories, $wpdb;
    477     $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $tablelinkcategories WHERE cat_id=$id");
     476    global $wpdb;
     477    $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
    478478    if ('' == $auto_toggle)
    479479        $auto_toggle = 'N';
    … …  
    493493function links_popup_script($text = 'Links', $width=400, $height=400,
    494494                            $file='links.all.php', $count = true) {
    495    global $tablelinks;
    496495   if ($count == true) {
    497       $counts = $wpdb->get_var("SELECT count(*) FROM $tablelinks");
     496      $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
    498497   }
    499498
    … …  
    519518 *
    520519 * Output a list of all links, listed by category, using the
    521  * settings in $tablelinkcategories and output it as a nested
     520 * settings in $wpdb->linkcategories and output it as a nested
    522521 * HTML unordered list.
    523522 *
    … …  
    527526 */
    528527function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
    529         global $tablelinkcategories, $tablelinks, $wpdb;
     528        global $wpdb;
    530529
    531530        $order = strtolower($order);
    … …  
    546545                        show_description, show_rating, show_updated, sort_order,
    547546                        sort_desc, list_limit
    548                 FROM `$tablelinks`
    549                 LEFT JOIN `$tablelinkcategories` ON (link_category = cat_id)
     547                FROM `$wpdb->links`
     548                LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
    550549                WHERE link_visible =  'Y'
    551550                        AND list_limit <> 0
  • trunk/wp-includes/template-functions-author.php

    r1203 r1355  
    7878
    7979function get_author_link($echo = false, $author_id, $author_nicename) {
    80     global $wpdb, $tableusers, $post, $querystring_start, $querystring_equal, $cache_userdata;
     80    global $wpdb, $post, $querystring_start, $querystring_equal, $cache_userdata;
    8181    $auth_ID = $author_id;
    8282    $permalink_structure = get_settings('permalink_structure');
    … …  
    127127
    128128function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
    129     global $tableusers, $wpdb, $blogfilename;
     129    global $wpdb, $blogfilename;
    130130
    131     $query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $tableusers " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
     131    $query = "SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_nickname <> 'admin' " : '') . "ORDER BY user_nickname";
    132132    $authors = $wpdb->get_results($query);
    133133
  • trunk/wp-includes/template-functions-category.php

    r1328 r1355  
    22
    33function get_the_category() {
    4     global $post, $tablecategories, $tablepost2cat, $wpdb, $category_cache;
     4    global $post, $wpdb, $category_cache;
    55    if ($category_cache[$post->ID]) {
    66        return $category_cache[$post->ID];
    … …  
    88        $categories = $wpdb->get_results("
    99            SELECT category_id, cat_name, category_nicename, category_description, category_parent
    10             FROM  $tablecategories, $tablepost2cat
    11             WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
     10            FROM  $wpdb->categories, $wpdb->post2cat
     11            WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $post->ID
    1212            ");
    1313   
    … …  
    1717
    1818function get_category_link($echo = false, $category_id, $category_nicename) {
    19     global $wpdb, $tablecategories, $post, $querystring_start, $querystring_equal, $cache_categories;
     19    global $wpdb, $post, $querystring_start, $querystring_equal, $cache_categories;
    2020    $cat_ID = $category_id;
    2121    $permalink_structure = get_settings('permalink_structure');
    … …  
    124124
    125125function get_the_category_by_ID($cat_ID) {
    126     global $tablecategories, $cache_categories, $wpdb;
     126    global $cache_categories, $wpdb;
    127127    if ( !$cache_categories[$cat_ID] ) {
    128         $cat_name = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'");
     128        $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
    129129        $cache_categories[$cat_ID]->cat_name = $cat_name;
    130130    } else {
    … …  
    135135
    136136function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
    137     global $tablecategories, $cache_categories;
    138     $chain = "";
     137    global $cache_categories;
     138    $chain = '';
    139139    $parent = $cache_categories[$id];
    140140    if ($nicename) {
    … …  
    153153
    154154function get_category_children($id, $before = '/', $after = '') {
    155     global $tablecategories, $cache_categories;
     155    global $cache_categories;
    156156    $c_cache = $cache_categories; // Can't do recursive foreach on a global, have to make a copy
    157157    $chain = '';
    … …  
    185185
    186186function category_description($category = 0) {
    187     global $cat, $wpdb, $tablecategories, $cache_categories;
     187    global $cat, $wpdb, $cache_categories;
    188188    if (!$category) $category = $cat;
    189189    $category_description = $cache_categories[$category]->category_description;
    … …  
    196196        $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE,
    197197        $selected=0, $hide=0) {
    198     global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
     198    global $wpdb;
    199199    global $querystring_start, $querystring_equal, $querystring_separator;
    200200    if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/' . get_settings('blogfilename');
    … …  
    204204    $query = "
    205205        SELECT cat_ID, cat_name, category_nicename,category_parent,
    206         COUNT($tablepost2cat.post_id) AS cat_count,
     206        COUNT($wpdb->post2cat.post_id) AS cat_count,
    207207        DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    208         FROM $tablecategories LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
    209         LEFT JOIN $tableposts ON (ID = post_id)
     208        FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
     209        LEFT JOIN $wpdb->posts ON (ID = post_id)
    210210        WHERE cat_ID > 0
    211211        ";
    … …  
    266266
    267267function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '') {
    268         global $tablecategories, $tableposts, $tablepost2cat, $wpdb, $category_posts;
     268        global $wpdb, $category_posts;
    269269        global $querystring_start, $querystring_equal, $querystring_separator;
    270270        // Optiondates now works
    … …  
    288288                $query  = "
    289289                        SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
    290                         FROM $tablecategories
     290                        FROM $wpdb->categories
    291291                        WHERE cat_ID > 0 $exclusions
    292292                        ORDER BY $sort_column $sort_order";
    … …  
    296296        if (!count($category_posts)) {
    297297                $cat_counts = $wpdb->get_results("      SELECT cat_ID,
    298                 COUNT($tablepost2cat.post_id) AS cat_count
    299                 FROM $tablecategories
    300                 INNER JOIN $tablepost2cat ON (cat_ID = category_id)
    301                 INNER JOIN $tableposts ON (ID = post_id)
     298                COUNT($wpdb->post2cat.post_id) AS cat_count
     299                FROM $wpdb->categories
     300                INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
     301                INNER JOIN $wpdb->posts ON (ID = post_id)
    302302                WHERE post_status = 'publish' $exclusions
    303303                GROUP BY category_id");
    … …  
    312312                $cat_dates = $wpdb->get_results("       SELECT cat_ID,
    313313                DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    314                 FROM $tablecategories
    315                 LEFT JOIN $tablepost2cat ON (cat_ID = category_id)
    316                 LEFT JOIN $tableposts ON (ID = post_id)
     314                FROM $wpdb->categories
     315                LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
     316                LEFT JOIN $wpdb->posts ON (ID = post_id)
    317317                WHERE post_status = 'publish' $exclusions
    318318                GROUP BY category_id");
  • trunk/wp-includes/template-functions-comment.php

    r1255 r1355  
    2727
    2828function comments_number($zero='No Comments', $one='1 Comment', $more='% Comments', $number='') {
    29     global $id, $comment, $tablecomments, $wpdb, $comment_count_cache;
    30     if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1'");
     29    global $id, $comment, $wpdb, $comment_count_cache;
     30    if ('' == $comment_count_cache["$id"]) $number = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1'");
    3131        else $number = $comment_count_cache["$id"];
    3232    if ($number == 0) {
    … …  
    5757
    5858function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
    59     global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $tablecomments, $cookiehash;
     59    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb, $cookiehash;
    6060    global $querystring_start, $querystring_equal, $querystring_separator;
    6161    global $comment_count_cache, $single;
    6262        if (!$single) {
    6363    if ('' == $comment_count_cache["$id"]) {
    64         $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $tablecomments WHERE comment_post_ID = $id AND comment_approved = '1';");
     64        $number = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
    6565    } else {
    6666        $number = $comment_count_cache["$id"];
  • trunk/wp-includes/template-functions-general.php

    r1301 r1355  
    9292
    9393function wp_title($sep = '&raquo;', $display = true) {
    94     global $wpdb, $tableposts, $tablecategories;
     94    global $wpdb;
    9595    global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
    9696
    … …  
    102102    }
    103103    if (!empty($category_name)) {
    104         $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
     104        $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"));
    105105    }
    106106
    … …  
    137137
    138138function single_post_title($prefix = '', $display = true) {
    139     global $p, $name, $wpdb, $tableposts;
     139    global $p, $name, $wpdb;
    140140    if (intval($p) || '' != $name) {
    141141        if (!$p) {
    142             $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'");
     142            $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
    143143        }
    144144        $post_data = get_postdata($p);
    … …  
    203203
    204204function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
    205     global $tableposts;
    206205    global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb;
    207206
    … …  
    244243
    245244    if ('monthly' == $type) {
    246         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     245        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
    247246        if ($arcresults) {
    248247            $afterafter = $after;
    … …  
    259258        }
    260259    } elseif ('daily' == $type) {
    261         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     260        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    262261        if ($arcresults) {
    263262            foreach ($arcresults as $arcresult) {
    … …  
    270269    } elseif ('weekly' == $type) {
    271270        $start_of_week = get_settings('start_of_week');
    272         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     271        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    273272        $arc_w_last = '';
    274273        if ($arcresults) {
    … …  
    289288        }
    290289    } elseif ('postbypost' == $type) {
    291         $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
     290        $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    292291        if ($arcresults) {
    293292            foreach ($arcresults as $arcresult) {
    … …  
    308307
    309308function get_calendar($daylength = 1) {
    310     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $tableposts, $posts;
     309    global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
    311310
    312311    // Quick check. If we have no posts at all, abort!
    313312    if (!$posts) {
    314         $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
     313        $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
    315314        if (!$gotsome)
    316315            return;
    … …  
    350349    // Get the next and previous month and year with at least one post
    351350    $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    352             FROM $tableposts
     351            FROM $wpdb->posts
    353352            WHERE post_date < '$thisyear-$thismonth-01'
    354353            AND post_status = 'publish'
    … …  
    356355                              LIMIT 1");
    357356    $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
    358             FROM $tableposts
     357            FROM $wpdb->posts
    359358            WHERE post_date >  '$thisyear-$thismonth-01'
    360359            AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
    … …  
    410409    // Get days with posts
    411410    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
    412             FROM $tableposts WHERE MONTH(post_date) = $thismonth
     411            FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
    413412            AND YEAR(post_date) = $thisyear
    414413            AND post_status = 'publish'
    … …  
    434433    $ak_titles_for_day = array();
    435434    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
    436                                          ."FROM $tableposts "
     435                                         ."FROM $wpdb->posts "
    437436                                         ."WHERE YEAR(post_date) = '$thisyear' "
    438437                                         ."AND MONTH(post_date) = '$thismonth' "
  • trunk/wp-includes/template-functions-links.php

    r1305 r1355  
    2828
    2929function get_permalink($id=false) {
    30     global $post, $wpdb, $tableposts;
     30    global $post, $wpdb;
    3131    global $querystring_start, $querystring_equal;
    3232
    … …  
    5959        }
    6060    } else { // if an ID is given
    61         $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
     61        $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $wpdb->posts WHERE ID = $id");
    6262        if ('' != get_settings('permalink_structure')) {
    6363            $unixtime = strtotime($idpost->post_date);
  • trunk/wp-includes/template-functions-post.php

    r1254 r1355  
    276276
    277277function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
    278     global $tableposts, $id, $post, $wpdb;
     278    global $id, $post, $wpdb;
    279279    global $p, $posts, $posts_per_page, $s, $single;
    280280    global $querystring_start, $querystring_equal, $querystring_separator;
    … …  
    300300
    301301        $limitprev--;
    302         $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
     302        $lastpost = @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts WHERE post_date < '$current_post_date' AND post_status = 'publish' $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev, 1");
    303303        if ($lastpost) {
    304304            $string = '<a href="'.get_permalink($lastpost->ID).'">'.$previous;
    … …  
    314314
    315315function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
    316     global $tableposts, $posts_per_page, $post, $wpdb, $single;
     316    global $posts_per_page, $post, $wpdb, $single;
    317317    if(1 == $posts_per_page || 1 == $single) {
    318318
    … …  
    338338        $limitnext--;
    339339
    340         $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
     340        $nextpost = @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $sqlcat $sql_exclude_cats AND ID != $post->ID ORDER BY post_date ASC LIMIT $limitnext,1");
    341341        if ($nextpost) {
    342342            $string = '<a href="'.get_permalink($nextpost->ID).'">'.$next;
  • trunk/wp-includes/wp-db.php

    r1218 r1355  
    1919        var $last_query;
    2020        var $col_info;
     21
     22        // Our tables
     23        var $posts;
     24        var $users;
     25        var $categories;
     26        var $post2cat;
     27        var $comments;
     28        var $links;
     29        var $linkcategories;
     30        var $options;
     31        var $optiontypes;
     32        var $optionvalues;
     33        var $optiongroups;
     34        var $optiongroup_options;
     35        var $postmeta;
    2136
    2237        // ==================================================================
  • trunk/wp-links-opml.php

    r1121 r1355  
    1313    $link_cat = intval($link_cat);
    1414    if ($link_cat != 0) {
    15         $sql_cat = "AND $tablelinks.link_category = $link_cat";
    16         $cat_name = $wpdb->get_var("SELECT $tablelinkcategories.cat_name FROM $tablelinkcategories WHERE $tablelinkcategories.cat_id = $link_cat");
     15        $sql_cat = "AND $wpdb->links.link_category = $link_cat";
     16        $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat");
    1717        if (!empty($cat_name)) {
    1818            $cat_name = ": category $cat_name";
    … …  
    2828    </head>
    2929    <body>
    30 <?php $sql = "SELECT $tablelinks.link_url, link_rss, $tablelinks.link_name, $tablelinks.link_category, $tablelinkcategories.cat_name
    31 FROM $tablelinks
    32  LEFT JOIN $tablelinkcategories on $tablelinks.link_category = $tablelinkcategories.cat_id
     30<?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name
     31FROM $wpdb->links
     32 LEFT JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
    3333 $sql_cat
    34  ORDER BY $tablelinkcategories.cat_name, $tablelinks.link_name \n";
     34 ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
    3535 //echo("<!-- $sql -->");
    3636 $prev_cat_id = 0;
  • trunk/wp-login.php

    r1302 r1355  
    7373        function login() {
    7474                global $wpdb, $log, $pwd, $error, $user_ID;
    75                 global $tableusers, $pass_is_md5;
     75                global $pass_is_md5;
    7676                $user_login = &$log;
    7777                $pwd = md5($pwd);
    … …  
    8787                }
    8888
    89                 $query = "SELECT ID, user_login, user_pass FROM $tableusers WHERE user_login = '$user_login' AND user_pass = '$password'";
     89                $query = "SELECT ID, user_login, user_pass FROM $wpdb->users WHERE user_login = '$user_login' AND user_pass = '$password'";
    9090       
    9191                $login = $wpdb->get_row($query);
    … …  
    209209    $user_pass = substr((MD5("time" . rand(1,16000))), 0, 6);
    210210        // now insert the new pass md5'd into the db
    211         $wpdb->query("UPDATE $tableusers SET user_pass = MD5('$user_pass') WHERE user_login = '$user_login'");
     211        $wpdb->query("UPDATE $wpdb->users SET user_pass = MD5('$user_pass') WHERE user_login = '$user_login'");
    212212        $message  = "Login: $user_login\r\n";
    213213        $message .= "Password: $user_pass\r\n";
  • trunk/wp-mail.php

    r1313 r1355  
    122122
    123123
    124         $sql = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES (1, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')";
     124        $sql = "INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES (1, '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')";
    125125
    126126        $result = $wpdb->query($sql);
    … …  
    139139
    140140        // Double check it's not there already
    141         $exists = $wpdb->get_row("SELECT * FROM $tablepost2cat WHERE post_id = $post_ID AND category_id = $post_category");
     141        $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category");
    142142
    143143         if (!$exists && $result) {
    144144                $wpdb->query("
    145                 INSERT INTO $tablepost2cat
     145                INSERT INTO $wpdb->post2cat
    146146                (post_id, category_id)
    147147                VALUES
  • trunk/wp-register.php

    r1309 r1355  
    7272
    7373        /* checking the login isn't already used by another user */
    74         $result = $wpdb->get_results("SELECT user_login FROM $tableusers WHERE user_login = '$user_login'");
     74        $result = $wpdb->get_results("SELECT user_login FROM $wpdb->users WHERE user_login = '$user_login'");
    7575    if (count($result) >= 1) {
    7676                die (__('<strong>ERROR</strong>: This login is already registered, please choose another one.'));
    … …  
    8787        $new_users_can_blog = get_settings('new_users_can_blog');
    8888
    89         $result = $wpdb->query("INSERT INTO $tableusers
     89        $result = $wpdb->query("INSERT INTO $wpdb->users
    9090                (user_login, user_pass, user_nickname, user_email, user_ip, user_browser, dateYMDhour, user_level, user_idmode)
    9191        VALUES
  • trunk/wp-settings.php

    r1243 r1355  
    1010error_reporting(E_ALL ^ E_NOTICE);
    1111
    12 // Table names
    13 $tableposts               = $table_prefix . 'posts';
    14 $tableusers               = $table_prefix . 'users';
    15 $tablesettings            = $table_prefix . 'settings'; // only used during upgrade
    16 $tablecategories          = $table_prefix . 'categories';
    17 $tablepost2cat            = $table_prefix . 'post2cat';
    18 $tablecomments            = $table_prefix . 'comments';
    19 $tablelinks               = $table_prefix . 'links';
    20 $tablelinkcategories      = $table_prefix . 'linkcategories';
    21 $tableoptions             = $table_prefix . 'options';
    22 $tableoptiontypes         = $table_prefix . 'optiontypes';
    23 $tableoptionvalues        = $table_prefix . 'optionvalues';
    24 $tableoptiongroups        = $table_prefix . 'optiongroups';
    25 $tableoptiongroup_options = $table_prefix . 'optiongroup_options';
    26 $tablepostmeta            = $table_prefix . 'postmeta';
    27 
    2812define('WPINC', 'wp-includes');
    29 
    3013require_once (ABSPATH . WPINC . '/wp-db.php');
    3114
     15// Table names
     16$wpdb->posts               = $table_prefix . 'posts';
     17$wpdb->users               = $table_prefix . 'users';
     18$wpdb->categories          = $table_prefix . 'categories';
     19$wpdb->post2cat            = $table_prefix . 'post2cat';
     20$wpdb->comments            = $table_prefix . 'comments';
     21$wpdb->links               = $table_prefix . 'links';
     22$wpdb->linkcategories      = $table_prefix . 'linkcategories';
     23$wpdb->options             = $table_prefix . 'options';
     24$wpdb->optiontypes         = $table_prefix . 'optiontypes';
     25$wpdb->optionvalues        = $table_prefix . 'optionvalues';
     26$wpdb->optiongroups        = $table_prefix . 'optiongroups';
     27$wpdb->optiongroup_options = $table_prefix . 'optiongroup_options';
     28$wpdb->postmeta            = $table_prefix . 'postmeta';
     29
    3230$wpdb->hide_errors();
    33 $users = $wpdb->get_results("SELECT * FROM $tableusers");
     31$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
    3432if (!$users && !strstr($_SERVER['PHP_SELF'], 'install.php')) {
    3533        die("It doesn't look like you've installed WP yet. Try running <a href='wp-admin/install.php'>install.php</a>.");
  • trunk/wp-trackback.php

    r1150 r1355  
    2929                trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
    3030
    31         $pingstatus = $wpdb->get_var("SELECT ping_status FROM $tableposts WHERE ID = $tb_id");
     31        $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
    3232
    3333        if ('closed' == $pingstatus)
    … …  
    7373        }
    7474
    75         $result = $wpdb->query("INSERT INTO $tablecomments
     75        $result = $wpdb->query("INSERT INTO $wpdb->comments
    7676        (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved)
    7777        VALUES
  • trunk/xmlrpc.php

    r1351 r1355  
    164164        function blogger_getRecentPosts($args) {
    165165
    166           global $tableposts, $wpdb;
     166          global $wpdb;
    167167
    168168          $blog_ID    = $args[1]; /* though we don't use it yet */
    … …  
    181181          }
    182182
    183           $sql = "SELECT * FROM $tableposts ORDER BY post_date DESC".$limit;
     183          $sql = "SELECT * FROM $wpdb->posts ORDER BY post_date DESC".$limit;
    184184          $result = $wpdb->get_results($sql);
    185185
    … …  
    323323        function blogger_newPost($args) {
    324324
    325           global $tableposts, $wpdb;
     325          global $wpdb;
    326326
    327327          $blog_ID    = $args[1]; /* though we don't use it yet */
    … …  
    376376
    377377function wp_insert_post($postarr = array()) {
    378         global $wpdb, $tableposts, $post_default_category;
     378        global $wpdb, $post_default_category;
    379379       
    380380        // export array as variables
    … …  
    401401                $post_date_gmt = get_gmt_from_date($post_date);
    402402       
    403         $sql = "INSERT INTO $tableposts
     403        $sql = "INSERT INTO $wpdb->posts
    404404                (post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name)
    405405                VALUES ('$post_author', '$post_date', '$post_date_gmt', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_cat', '$post_status', '$post_name')";
    … …  
    417417
    418418function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
    419         global $wpdb, $tablepost2cat;
     419        global $wpdb;
    420420        // If $post_categories isn't already an array, make it one:
    421421        if (!is_array($post_categories)) {
    … …  
    431431        $old_categories = $wpdb->get_col("
    432432                SELECT category_id
    433                 FROM $tablepost2cat
     433                FROM $wpdb->post2cat
    434434                WHERE post_id = $post_ID");
    435435       
    … …  
    454454                foreach ($delete_cats as $del) {
    455455                        $wpdb->query("
    456                                 DELETE FROM $tablepost2cat
     456                                DELETE FROM $wpdb->post2cat
    457457                                WHERE category_id = $del
    458458                                        AND post_id = $post_ID
    … …  
    471471                foreach ($add_cats as $new_cat) {
    472472                        $wpdb->query("
    473                                 INSERT INTO $tablepost2cat (post_id, category_id)
     473                                INSERT INTO $wpdb->post2cat (post_id, category_id)
    474474                                VALUES ($post_ID, $new_cat)");
    475475
    … …  
    481481
    482482function wp_get_post_cats($blogid = '1', $post_ID = 0) {
    483         global $wpdb, $tablepost2cat;
     483        global $wpdb;
    484484       
    485485        $sql = "SELECT category_id
    486                 FROM $tablepost2cat
     486                FROM $wpdb->post2cat
    487487                WHERE post_id = $post_ID
    488488                ORDER BY category_id";
Note: See TracChangeset for help on using the changeset viewer.