Make WordPress Core


Ignore:
Timestamp:
03/11/2004 08:51:50 AM (22 years ago)
Author:
saxmatt
Message:

More options improvements.

File:
1 edited

Legend:

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

    r957 r969  
    6565    $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)");
    6666//  die(var_dump($options));
     67
     68// HACK
     69// Options that if not there have 0 value but need to be something like "closed"
     70$nonbools = array('default_ping_status', 'default_comment_status');
    6771    if ($options) {
    6872        foreach ($options as $option) {
     
    7276                $new_val = $_POST[$option->option_name];
    7377                if (!$new_val) $new_val = 0;
    74 
    75                 if ($new_val != $old_val) {
    76                     // get type and validate
    77                     $msg = validate_option($option, $this_name, $new_val);
    78                     if ($msg == '') {
    79                         //no error message
    80                         $result = $wpdb->query("UPDATE $tableoptions SET option_value = '$new_val' WHERE option_id = $option->option_id");
    81                         if (!$result) {
    82                             $db_errors .= " SQL error while saving $this_name. ";
    83                         } else {
    84                             ++$any_changed;
    85                         }
    86                     } else {
    87                         $validation_message .= $msg;
    88                     }
     78                if( in_array($option->option_name, $nonbools) && $new_val == 0 ) $new_value = 'closed';
     79                if ($new_val !== $old_val) {
     80                    $query = "UPDATE $tableoptions SET option_value = '$new_val' WHERE option_id = $option->option_id";
     81                    $result = $wpdb->query($query);
     82                    //if( in_array($option->option_name, $nonbools)) die('boo'.$query);
     83                    if (!$result) {
     84                        $db_errors .= " SQL error while saving $this_name. ";
     85                    } else {
     86                        ++$any_changed;
     87                    }
    8988                }
    9089            }
     
    143142<ul id="adminmenu2">
    144143<li><a href="options-general.php">General</a></li>
     144    <li><a href="options-writing.php">Writing</a></li>
     145    <li><a href="options-reading.php">Reading</a></li>
     146    <li><a href="options-discussion.php">Discussion</a></li>
    145147<?php
    146148    //Iterate through the available option groups.
Note: See TracChangeset for help on using the changeset viewer.