PHP Cross Reference of WordPress Subversion HEAD

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]

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 ( (array) $_POST as $key => $value) {
  22              if ( !in_array($key, array('_wpnonce', '_wp_http_referer')) )
  23                  $options[] = $key;
  24          }
  25      } else {
  26          $options = explode(',', stripslashes($_POST['page_options']));
  27      }
  28  
  29      if ($options) {
  30          foreach ($options as $option) {
  31              $option = trim($option);
  32              $value = $_POST[$option];
  33              if(!is_array($value))    $value = trim($value);
  34              $value = stripslashes_deep($value);
  35              update_option($option, $value);
  36          }
  37      }
  38  
  39      $goback = add_query_arg('updated', 'true', wp_get_referer());
  40      wp_redirect($goback);
  41      break;
  42  
  43  default:
  44      include ('admin-header.php'); ?>
  45  
  46  <div class="wrap">
  47    <h2><?php _e('All Options'); ?></h2>
  48    <form name="form" action="options.php" method="post" id="all-options">
  49    <?php wp_nonce_field('update-options') ?>
  50    <input type="hidden" name="action" value="update" />
  51      <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Options &raquo;') ?>" /></p>
  52    <table width="98%">
  53  <?php
  54  $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
  55  
  56  foreach ( (array) $options as $option) :
  57      $disabled = '';
  58      $option->option_name = attribute_escape($option->option_name);
  59      if ( is_serialized($option->option_value) ) {
  60          if ( is_serialized_string($option->option_value) ) {
  61              // this is a serialized string, so we should display it
  62              $value = maybe_unserialize($option->option_value);
  63              $options_to_update[] = $option->option_name;
  64              $class = 'all-options';
  65          } else {
  66              $value = 'SERIALIZED DATA';
  67              $disabled = ' disabled="disabled"';
  68              $class = 'all-options disabled';
  69          }
  70      } else {
  71          $value = $option->option_value;
  72          $options_to_update[] = $option->option_name;
  73          $class = 'all-options';
  74      }
  75      echo "
  76  <tr>
  77      <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
  78  <td>";
  79  
  80      if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>" . wp_specialchars($value) . "</textarea>";
  81      else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . attribute_escape($value) . "'$disabled />";
  82  
  83      echo "</td>
  84  </tr>";
  85  endforeach;
  86  ?>
  87    </table>
  88  <?php $options_to_update = implode(',', $options_to_update); ?>
  89  <p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Update Options &raquo;') ?>" /></p>
  90    </form>
  91  </div>
  92  
  93  
  94  <?php
  95  break;
  96  } // end switch
  97  
  98  include ('admin-footer.php');
  99  ?>


Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs Cross-referenced by PHPXref 0.6 and RedAlt