Make WordPress Core


Ignore:
Timestamp:
11/12/2005 09:36:20 AM (21 years ago)
Author:
ryan
Message:

Cleanup options save.

File:
1 edited

Legend:

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

    r3023 r3054  
    3434        if (!$_POST['page_options']) {
    3535                foreach ($_POST as $key => $value) {
    36                         $option_names[] = "'$key'";
     36                        $options[] = "'$key'";
    3737                }
    38                 $option_names = implode(',', $option_names);
    3938        } else {
    40                 $option_names = stripslashes($_POST['page_options']);
     39                $options = explode(',', stripslashes($_POST['page_options']));
    4140        }
    42 
    43     $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)");
    4441
    4542        // Save for later.
     
    4744        $old_home = get_settings('home');
    4845
    49 // HACK
    50 // Options that if not there have 0 value but need to be something like "closed"
    51     $nonbools = array('default_ping_status', 'default_comment_status');
    52     if ($options) {
    53                 $options = apply_filters( 'options_to_update' , $options );
    54         foreach ($options as $option) {
    55             $old_val = $option->option_value;
    56             $new_val = trim($_POST[$option->option_name]);
    57             if( in_array($option->option_name, $nonbools) && ( $new_val == '0' || $new_val == '') )
    58                                 $new_val = 'closed';
    59             if ($new_val !== $old_val) {
    60                 $result = $wpdb->query("UPDATE $wpdb->options SET option_value = '$new_val' WHERE option_name = '$option->option_name'");
    61                 wp_cache_set($option->option_name, $new_val, 'options');
    62                                 $any_changed++;
    63                         }
     46        // HACK
     47        // Options that if not there have 0 value but need to be something like "closed"
     48        $nonbools = array('default_ping_status', 'default_comment_status');
     49        if ($options) {
     50          foreach ($options as $option) {
     51            $option = trim($option);
     52            $value = trim(stripslashes($_POST[$option]));
     53            if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
     54              $value = 'closed';
     55
     56            if ( update_option($option, $value) )
     57              $any_changed++;
     58          }
    6459        }
    65         unset($cache_settings); // so they will be re-read
    66         get_settings('siteurl'); // make it happen now
    67     } // end if options
    6860   
    69     if ($any_changed) {
     61        if ($any_changed) {
    7062                        // If siteurl or home changed, reset cookies.
    7163                        if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
Note: See TracChangeset for help on using the changeset viewer.