[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-admin/ -> options.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  $title = __('Options');
   5  $this_file = 'options.php';
   6  $parent_file = 'options-general.php';
   7  
   8  wp_reset_vars(array('action'));
   9  
  10  if ( !current_user_can('manage_options') )
  11      wp_die(__('Cheatin&#8217; uh?'));
  12  
  13  switch($action) {
  14  
  15  case 'update':
  16      $any_changed = 0;
  17  
  18      check_admin_referer('update-options');
  19  
  20      if (!$_POST['page_options']) {
  21          foreach ($_POST as $key => $value) {
  22              $options[] = $key;
  23          }
  24      } else {
  25          $options = explode(',', stripslashes($_POST['page_options']));
  26      }
  27  
  28      // Save for later.
  29      $old_siteurl = get_settings('siteurl');
  30      $old_home = get_settings('home');
  31  
  32      // HACK
  33      // Options that if not there have 0 value but need to be something like "closed"
  34      $nonbools = array('default_ping_status', 'default_comment_status');
  35      if ($options) {
  36          foreach ($options as $option) {
  37              $option = trim($option);
  38              $value = trim(stripslashes($_POST[$option]));
  39                  if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
  40                  $value = 'closed';
  41  
  42              if( $option == 'blogdescription' || $option == 'blogname' )
  43                  if (current_user_can('unfiltered_html') == false)
  44                      $value = wp_filter_post_kses( $value );
  45  
  46              if (update_option($option, $value) ) {
  47                  $any_changed++;
  48              }
  49          }
  50      }
  51      
  52      if ($any_changed) {
  53              // If siteurl or home changed, reset cookies.
  54              if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
  55                  // If home changed, write rewrite rules to new location.
  56                  $wp_rewrite->flush_rules();
  57                  // Clear cookies for old paths.
  58                  wp_clearcookie();
  59                  // Set cookies for new paths.
  60                  wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
  61              }
  62  
  63              //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
  64      }
  65      
  66      $referred = remove_query_arg('updated' , wp_get_referer());
  67      $goback = add_query_arg('updated', 'true', wp_get_referer());
  68      $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
  69      wp_redirect($goback);
  70      break;
  71  
  72  default:
  73      include ('admin-header.php'); ?>
  74  
  75  <div class="wrap">
  76    <h2><?php _e('All options'); ?></h2>
  77    <form name="form" action="options.php" method="post">
  78    <?php wp_nonce_field('update-options') ?>
  79    <input type="hidden" name="action" value="update" />
  80    <table width="98%">
  81  <?php
  82  $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
  83  
  84  foreach ($options as $option) :
  85      $value = wp_specialchars($option->option_value, 'single');
  86      echo "
  87  <tr>
  88      <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
  89      <td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
  90      <td>$option->option_description</td>
  91  </tr>";
  92  endforeach;
  93  ?>
  94    </table>
  95  <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings &raquo;') ?>" /></p>
  96    </form>
  97  </div>
  98  
  99  
 100  <?php
 101  break;
 102  } // end switch
 103  
 104  include ('admin-footer.php');
 105  ?>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana