Make WordPress Core


Ignore:
Timestamp:
11/15/2003 08:58:18 AM (23 years ago)
Author:
saxmatt
Message:

Cleaning up comment moderation and the comment code in general. More to do tomorrow with regards to wp-moderation.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-072-to-073.php

    r516 r549  
    7777}
    7878
    79 $wpdb->query("INSERT INTO `$tableoptions` (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`) VALUES ('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', 'How the permalinks for your site are constructed.', '8');");
    80 ?>
    81   <strong>Done.</strong></p>
     79if (!$wpdb->get_var("SELECT option_name FROM $tableoptions WHERE option_name = 'permalink_structure'")) { // If it's not already there
     80    $wpdb->query("INSERT INTO `$tableoptions`
     81        (`option_id`, `blog_id`, `option_name`, `option_can_override`, `option_type`, `option_value`, `option_width`, `option_height`, `option_description`, `option_admin_level`)
     82        VALUES
     83        ('', '0', 'permalink_structure', 'Y', '3', '', '20', '8', 'How the permalinks for your site are constructed. See <a href=\"wp-options-permalink.php\">permalink options page</a> for necessary mod_rewrite rules and more information.', '8');");
     84    }
     85?>
     86  Done with the name game. Now a little option action. </p>
    8287  <p>Now on to <a href="upgrade-072-to-073.php?step=2">step 2</a>.</p>
    8388<?php
     
    101106        echo ' .';
    102107        flush();
    103         // add link to date format help page
    104         $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"help/en/dateformats.help.html\">help</a> for format characters' WHERE option_id = 52");
    105         $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"help/en/dateformats.help.html\">help</a> for format characters' WHERE option_id = 53");
    106         echo ' .';
    107         flush();
    108 ?>
    109     <strong>Done.</strong></p>
    110 <p>See, that didn&#8217;t hurt a bit. All done!</p>
     108        // add link to php date format. this could be to a wordpress.org page in the future
     109        $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 52");
     110        $wpdb->query("UPDATE $tableoptions SET option_description = 'see <a href=\"http://php.net/date\">help</a> for format characters' WHERE option_id = 53");
     111        echo ' .';
     112        flush();
     113?>
     114    <strong>Done with the options updates. Now for a bit of comment action</strong></p>
     115<?php
     116$result = '';
     117$error_count = 0;
     118$continue = true;
     119
     120// Insert new column "comment_approved" to $tablecomments
     121if ($continue) {
     122    $ddl = "ALTER TABLE $tablecomments ADD COLUMN comment_approved ENUM('0', '1') DEFAULT '1' NOT NULL";
     123    if (maybe_add_column($tablecomments, $tablecol, $ddl)) {
     124        $wpdb->query("ALTER TABLE $tablecomments ADD INDEX (comment_approved)");
     125    }
     126}
     127
     128// Insert new option "comment_moderation" to settings   
     129if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'")) {
     130    $wpdb->query("INSERT INTO $tableoptions
     131        (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)
     132        VALUES
     133        ('0', '0', 'comment_moderation', 'Y', '5',' none', 20, 8, 'If enabled, comments will only be shown after they have been approved.', 8)");
     134}
     135
     136// attach option to group "General blog settings"
     137if ($continue) {
     138    $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'comment_moderation'");     
     139    $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'");
     140   
     141    $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'");
     142   
     143    ++$seq;
     144
     145    $wpdb->query("INSERT INTO $tableoptiongroup_options
     146        (group_id, option_id, seq)
     147        VALUES
     148        ('$gid', '$oid', '$seq')");
     149}
     150
     151// Insert option values for new option "comment_moderation"
     152if ($continue) {
     153    $ddl = array();     
     154    $ddl[] = "INSERT INTO $tableoptionvalues
     155        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
     156        VALUES
     157        ('$oid', 'none', 'None', NULL, NULL, 1)";
     158    $ddl[] = "INSERT INTO $tableoptionvalues
     159        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
     160        VALUES
     161        ('$oid', 'manual', 'Manual', NULL, NULL, 2)";
     162    $ddl[] = "INSERT INTO $tableoptionvalues
     163        (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq)
     164        VALUES
     165        ('$oid','auto', 'Automatic', NULL, NULL, 3)";
     166       
     167    foreach ($ddl as $query) {
     168        $wpdb->query($query);
     169    }
     170   
     171}
     172
     173// Insert new option "moderation_notify" to settings   
     174if (!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'")) {
     175    $wpdb->query("INSERT INTO $tableoptions
     176        (option_id, blog_id, option_name, option_can_override, option_type, option_value, option_width, option_height, option_description, option_admin_level)
     177        VALUES
     178        ('0', '0', 'moderation_notify' , 'Y', '2', '1', 20, 8, 'Set this to true if you want to be notified about new comments that wait for approval', 8)");
     179}
     180
     181// attach option to group "General blog settings"
     182if ($continue) {
     183    $oid = $wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'moderation_notify'");       
     184    $gid = $wpdb->get_var("SELECT group_id FROM $tableoptiongroups WHERE group_name = 'General blog settings'");
     185   
     186    $seq = $wpdb->get_var("SELECT MAX(seq) FROM $tableoptiongroup_options WHERE group_id = '$gid'");
     187
     188    ++$seq;
     189    $wpdb->query("INSERT INTO $tableoptiongroup_options
     190        (group_id, option_id, seq)
     191        VALUES
     192        ('$gid', '$oid', '$seq')");
     193}
     194?>
     195<p>Comment spammers should now watch out for you.</p>
     196<p>See, that didn&#8217;t hurt a bit (again). All done!</p>
    111197<?php
    112198    break;
Note: See TracChangeset for help on using the changeset viewer.