2 require_once('admin.php');
4 $title = __('Options');
5 $this_file = 'options.php';
6 $parent_file = 'options-general.php';
8 $wpvarstoreset = array('action');
9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
10 $wpvar = $wpvarstoreset[$i];
11 if (!isset($$wpvar)) {
12 if (empty($_POST["$wpvar"])) {
13 if (empty($_GET["$wpvar"])) {
16 $$wpvar = $_GET["$wpvar"];
19 $$wpvar = $_POST["$wpvar"];
24 if ( !current_user_can('manage_options') )
25 die ( __('Cheatin’ uh?') );
27 function sanitize_option($option, $value) {
31 $value = sanitize_email($value);
34 case 'default_post_edit_rows':
35 case 'mailserver_port':
36 case 'comment_max_links':
37 $value = abs((int) $value);
40 case 'posts_per_page':
42 $value = (int) $value;
43 if ( empty($value) ) $value = 1;
44 if ( $value < -1 ) $value = abs($value);
47 case 'default_ping_status':
48 case 'default_comment_status':
49 // Options that if not there have 0 value but need to be something like "closed"
50 if ( $value == '0' || $value == '')
54 case 'blogdescription':
56 if (current_user_can('unfiltered_html') == false)
57 $value = wp_filter_post_kses( $value );
61 $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value);
66 case 'mailserver_url':
67 case 'mailserver_login':
68 case 'mailserver_pass':
71 $value = strip_tags($value);
72 $value = wp_filter_kses($value);
76 $value = preg_replace('/[^0-9:.-]/', '', $value);
81 $value = clean_url($value);
93 check_admin_referer('update-options');
95 if ( !$_POST['page_options'] ) {
96 foreach ( (array) $_POST as $key => $value) {
97 if ( !in_array($key, array('_wpnonce', '_wp_http_referer')) )
101 $options = explode(',', stripslashes($_POST['page_options']));
105 $old_siteurl = get_settings('siteurl');
106 $old_home = get_settings('home');
109 foreach ($options as $option) {
110 $option = trim($option);
111 $value = trim(stripslashes($_POST[$option]));
112 $value = sanitize_option($option, $value);
114 if (update_option($option, $value) ) {
121 // If siteurl or home changed, reset cookies.
122 if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
123 // If home changed, write rewrite rules to new location.
124 $wp_rewrite->flush_rules();
125 // Clear cookies for old paths.
127 // Set cookies for new paths.
128 wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
131 //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
134 $referred = remove_query_arg('updated' , wp_get_referer());
135 $goback = add_query_arg('updated', 'true', wp_get_referer());
136 $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
137 wp_redirect($goback);
141 include('admin-header.php'); ?>
144 <h2><?php _e('All Options'); ?></h2>
145 <form name="form" action="options.php" method="post" id="all-options">
146 <?php wp_nonce_field('update-options') ?>
147 <input type="hidden" name="action" value="update" />
150 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
152 foreach ( (array) $options as $option) :
154 $option->option_name = attribute_escape($option->option_name);
155 if ( is_serialized($option->option_value) ) {
156 if ( is_serialized_string($option->option_value) ) {
157 // this is a serialized string, so we should display it
158 $value = maybe_unserialize($option->option_value);
159 $options_to_update[] = $option->option_name;
160 $class = 'all-options';
162 $value = 'SERIALIZED DATA';
163 $disabled = ' disabled="disabled"';
164 $class = 'all-options disabled';
167 $value = $option->option_value;
168 $options_to_update[] = $option->option_name;
169 $class = 'all-options';
173 <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
176 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>";
177 else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . attribute_escape($value) . "'$disabled />";
180 <td>$option->option_description</td>
185 <?php $options_to_update = implode(',', $options_to_update); ?>
186 <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 »') ?>" /></p>
195 include('admin-footer.php');