[ Index ]

PHP Cross Reference of Wordpress 2.9.1

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Options Management Administration Panel.
   4   *
   5   * Just allows for displaying of options.
   6   *
   7   * This isn't referenced or linked to, but will show all of the options and
   8   * allow editing. The issue is that serialized data is not supported to be
   9   * modified. Options can not be removed.
  10   *
  11   * @package WordPress
  12   * @subpackage Administration
  13   */
  14  
  15  /** WordPress Administration Bootstrap */
  16  require_once ('admin.php');
  17  
  18  $title = __('Settings');
  19  $this_file = 'options.php';
  20  $parent_file = 'options-general.php';
  21  
  22  wp_reset_vars(array('action'));
  23  
  24  $whitelist_options = array(
  25      'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'default_role', 'timezone_string' ),
  26      'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
  27      'misc' => array( 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path' ),
  28      'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
  29      'privacy' => array( 'blog_public' ),
  30      'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
  31      'writing' => array( 'default_post_edit_rows', 'use_smilies', 'ping_sites', 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ),
  32      'options' => array( '' ) );
  33  if ( !defined( 'WP_SITEURL' ) ) $whitelist_options['general'][] = 'siteurl';
  34  if ( !defined( 'WP_HOME' ) ) $whitelist_options['general'][] = 'home';
  35  
  36  $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
  37  
  38  if ( !current_user_can('manage_options') )
  39      wp_die(__('Cheatin&#8217; uh?'));
  40  
  41  switch($action) {
  42  
  43  case 'update':
  44      if ( isset($_POST[ 'option_page' ]) ) {
  45          $option_page = $_POST[ 'option_page' ];
  46          check_admin_referer( $option_page . '-options' );
  47      } else {
  48          // This is for back compat and will eventually be removed.
  49          $option_page = 'options';
  50          check_admin_referer( 'update-options' );
  51      }
  52  
  53      if ( !isset( $whitelist_options[ $option_page ] ) )
  54          wp_die( __( 'Error! Options page not found.' ) );
  55  
  56      if ( 'options' == $option_page ) {
  57          $options = explode(',', stripslashes( $_POST[ 'page_options' ] ));
  58      } else {
  59          $options = $whitelist_options[ $option_page ];
  60      }
  61  
  62      // Handle custom date/time formats
  63      if ( 'general' == $option_page ) {
  64          if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
  65              $_POST['date_format'] = $_POST['date_format_custom'];
  66          if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
  67              $_POST['time_format'] = $_POST['time_format_custom'];
  68          // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
  69          if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
  70              $_POST['gmt_offset'] = $_POST['timezone_string'];
  71              $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
  72              $_POST['timezone_string'] = '';
  73          }
  74      }
  75  
  76      if ( $options ) {
  77          foreach ( $options as $option ) {
  78              $option = trim($option);
  79              $value = null;
  80              if ( isset($_POST[$option]) )
  81                  $value = $_POST[$option];
  82              if ( !is_array($value) ) $value = trim($value);
  83              $value = stripslashes_deep($value);
  84              update_option($option, $value);
  85          }
  86      }
  87  
  88      $goback = add_query_arg( 'updated', 'true', wp_get_referer() );
  89      wp_redirect( $goback );
  90      break;
  91  
  92  default:
  93      include ('admin-header.php'); ?>
  94  
  95  <div class="wrap">
  96  <?php screen_icon(); ?>
  97    <h2><?php _e('All Settings'); ?></h2>
  98    <form name="form" action="options.php" method="post" id="all-options">
  99    <?php wp_nonce_field('options-options') ?>
 100    <input type="hidden" name="action" value="update" />
 101    <input type='hidden' name='option_page' value='options' />
 102    <table class="form-table">
 103  <?php
 104  $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
 105  
 106  foreach ( (array) $options as $option) :
 107      $disabled = '';
 108      $option->option_name = esc_attr($option->option_name);
 109      if ( is_serialized($option->option_value) ) {
 110          if ( is_serialized_string($option->option_value) ) {
 111              // this is a serialized string, so we should display it
 112              $value = maybe_unserialize($option->option_value);
 113              $options_to_update[] = $option->option_name;
 114              $class = 'all-options';
 115          } else {
 116              $value = 'SERIALIZED DATA';
 117              $disabled = ' disabled="disabled"';
 118              $class = 'all-options disabled';
 119          }
 120      } else {
 121          $value = $option->option_value;
 122          $options_to_update[] = $option->option_name;
 123          $class = 'all-options';
 124      }
 125      echo "
 126  <tr>
 127      <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
 128  <td>";
 129  
 130      if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>" . esc_html($value) . "</textarea>";
 131      else echo "<input class='regular-text $class' type='text' name='$option->option_name' id='$option->option_name' value='" . esc_attr($value) . "'$disabled />";
 132  
 133      echo "</td>
 134  </tr>";
 135  endforeach;
 136  ?>
 137    </table>
 138  <?php $options_to_update = implode(',', $options_to_update); ?>
 139  <p class="submit"><input type="hidden" name="page_options" value="<?php echo esc_attr($options_to_update); ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" class="button-primary" /></p>
 140    </form>
 141  </div>
 142  
 143  
 144  <?php
 145  include ('admin-footer.php');
 146  break;
 147  } // end switch
 148  
 149  ?>


Generated: Fri Jan 8 00:19:48 2010 Cross-referenced by PHPXref 0.7