home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-admin / options.php < prev    next >
Encoding:
PHP Script  |  2008-05-04  |  2.7 KB  |  99 lines

  1. <?php
  2. require_once('admin.php');
  3.  
  4. $title = __('Settings');
  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’ 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 Settings'); ?></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.   <table class="form-table">
  52. <?php
  53. $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
  54.  
  55. foreach ( (array) $options as $option) :
  56.     $disabled = '';
  57.     $option->option_name = attribute_escape($option->option_name);
  58.     if ( is_serialized($option->option_value) ) {
  59.         if ( is_serialized_string($option->option_value) ) {
  60.             // this is a serialized string, so we should display it
  61.             $value = maybe_unserialize($option->option_value);
  62.             $options_to_update[] = $option->option_name;
  63.             $class = 'all-options';
  64.         } else {
  65.             $value = 'SERIALIZED DATA';
  66.             $disabled = ' disabled="disabled"';
  67.             $class = 'all-options disabled';
  68.         }
  69.     } else {
  70.         $value = $option->option_value;
  71.         $options_to_update[] = $option->option_name;
  72.         $class = 'all-options';
  73.     }
  74.     echo "
  75. <tr>
  76.     <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
  77. <td>";
  78.  
  79.     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>";
  80.     else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . attribute_escape($value) . "'$disabled />";
  81.  
  82.     echo "</td>
  83. </tr>";
  84. endforeach;
  85. ?>
  86.   </table>
  87. <?php $options_to_update = implode(',', $options_to_update); ?>
  88. <p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" /></p>
  89.   </form>
  90. </div>
  91.  
  92.  
  93. <?php
  94. break;
  95. } // end switch
  96.  
  97. include('admin-footer.php');
  98. ?>
  99.