]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/options.php
Wordpress 3.5.2-scripts
[autoinstalls/wordpress.git] / wp-admin / options.php
1 <?php
2 /**
3  * Options Management Administration Screen.
4  *
5  * If accessed directly in a browser this page shows a list of all saved options
6  * along with editable fields for their values. Serialized data is not supported
7  * and there is no way to remove options via this page. It is not linked to from
8  * anywhere else in the admin.
9  *
10  * This file is also the target of the forms in core and custom options pages
11  * that use the Settings API. In this case it saves the new option values
12  * and returns the user to their page of origin.
13  *
14  * @package WordPress
15  * @subpackage Administration
16  */
17
18 /** WordPress Administration Bootstrap */
19 require_once('./admin.php');
20
21 $title = __('Settings');
22 $this_file = 'options.php';
23 $parent_file = 'options-general.php';
24
25 wp_reset_vars(array('action', 'option_page'));
26
27 $capability = 'manage_options';
28
29 if ( empty($option_page) ) // This is for back compat and will eventually be removed.
30         $option_page = 'options';
31 else
32         $capability = apply_filters( "option_page_capability_{$option_page}", $capability );
33
34 if ( !current_user_can( $capability ) )
35         wp_die(__('Cheatin&#8217; uh?'));
36
37 // Handle admin email change requests
38 if ( is_multisite() ) {
39         if ( ! empty($_GET[ 'adminhash' ] ) ) {
40                 $new_admin_details = get_option( 'adminhash' );
41                 $redirect = 'options-general.php?updated=false';
42                 if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) {
43                         update_option( 'admin_email', $new_admin_details[ 'newemail' ] );
44                         delete_option( 'adminhash' );
45                         delete_option( 'new_admin_email' );
46                         $redirect = 'options-general.php?updated=true';
47                 }
48                 wp_redirect( admin_url( $redirect ) );
49                 exit;
50         } elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) {
51                 delete_option( 'adminhash' );
52                 delete_option( 'new_admin_email' );
53                 wp_redirect( admin_url( 'options-general.php?updated=true' ) );
54                 exit;
55         }
56 }
57
58 if ( is_multisite() && !is_super_admin() && 'update' != $action )
59         wp_die(__('Cheatin&#8217; uh?'));
60
61 $whitelist_options = array(
62         'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
63         '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' ),
64         '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' ),
65         'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
66         'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' )
67 );
68 $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array();
69
70 $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
71
72 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
73         $whitelist_options['reading'][] = 'blog_charset';
74
75 if ( !is_multisite() ) {
76         if ( !defined( 'WP_SITEURL' ) )
77                 $whitelist_options['general'][] = 'siteurl';
78         if ( !defined( 'WP_HOME' ) )
79                 $whitelist_options['general'][] = 'home';
80
81         $whitelist_options['general'][] = 'admin_email';
82         $whitelist_options['general'][] = 'users_can_register';
83         $whitelist_options['general'][] = 'default_role';
84
85         $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
86         $whitelist_options['writing'][] = 'ping_sites';
87
88         $whitelist_options['media'][] = 'uploads_use_yearmonth_folders';
89
90         // If upload_url_path and upload_path are both default values, they're locked.
91         if ( get_option( 'upload_url_path' ) || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) {
92                 $whitelist_options['media'][] = 'upload_path';
93                 $whitelist_options['media'][] = 'upload_url_path';
94         }
95 } else {
96         $whitelist_options['general'][] = 'new_admin_email';
97         $whitelist_options['general'][] = 'WPLANG';
98
99         if ( apply_filters( 'enable_post_by_email_configuration', true ) )
100                 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
101 }
102
103 $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
104
105 /*
106  * If $_GET['action'] == 'update' we are saving settings sent from a settings page
107  */
108 if ( 'update' == $action ) {
109         if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
110                 $unregistered = true;
111                 check_admin_referer( 'update-options' );
112         } else {
113                 $unregistered = false;
114                 check_admin_referer( $option_page . '-options' );
115         }
116
117         if ( !isset( $whitelist_options[ $option_page ] ) )
118                 wp_die( __( '<strong>ERROR</strong>: options page not found.' ) );
119
120         if ( 'options' == $option_page ) {
121                 if ( is_multisite() && ! is_super_admin() )
122                         wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
123                 $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
124         } else {
125                 $options = $whitelist_options[ $option_page ];
126         }
127
128         // Handle custom date/time formats
129         if ( 'general' == $option_page ) {
130                 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
131                         $_POST['date_format'] = $_POST['date_format_custom'];
132                 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
133                         $_POST['time_format'] = $_POST['time_format_custom'];
134                 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
135                 if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
136                         $_POST['gmt_offset'] = $_POST['timezone_string'];
137                         $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
138                         $_POST['timezone_string'] = '';
139                 }
140         }
141
142         if ( $options ) {
143                 foreach ( $options as $option ) {
144                         if ( $unregistered )
145                                 _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
146
147                         $option = trim( $option );
148                         $value = null;
149                         if ( isset( $_POST[ $option ] ) ) {
150                                 $value = $_POST[ $option ];
151                                 if ( ! is_array( $value ) )
152                                         $value = trim( $value );
153                                 $value = stripslashes_deep( $value );
154                         }
155                         update_option( $option, $value );
156                 }
157         }
158
159         /**
160          * Handle settings errors and return to options page
161          */
162         // If no settings errors were registered add a general 'updated' message.
163         if ( !count( get_settings_errors() ) )
164                 add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
165         set_transient('settings_errors', get_settings_errors(), 30);
166
167         /**
168          * Redirect back to the settings page that was submitted
169          */
170         $goback = add_query_arg( 'settings-updated', 'true',  wp_get_referer() );
171         wp_redirect( $goback );
172         exit;
173 }
174
175 include('./admin-header.php'); ?>
176
177 <div class="wrap">
178 <?php screen_icon(); ?>
179   <h2><?php esc_html_e('All Settings'); ?></h2>
180   <form name="form" action="options.php" method="post" id="all-options">
181   <?php wp_nonce_field('options-options') ?>
182   <input type="hidden" name="action" value="update" />
183   <input type='hidden' name='option_page' value='options' />
184   <table class="form-table">
185 <?php
186 $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
187
188 foreach ( (array) $options as $option ) :
189         $disabled = false;
190         if ( $option->option_name == '' )
191                 continue;
192         if ( is_serialized( $option->option_value ) ) {
193                 if ( is_serialized_string( $option->option_value ) ) {
194                         // this is a serialized string, so we should display it
195                         $value = maybe_unserialize( $option->option_value );
196                         $options_to_update[] = $option->option_name;
197                         $class = 'all-options';
198                 } else {
199                         $value = 'SERIALIZED DATA';
200                         $disabled = true;
201                         $class = 'all-options disabled';
202                 }
203         } else {
204                 $value = $option->option_value;
205                 $options_to_update[] = $option->option_name;
206                 $class = 'all-options';
207         }
208         $name = esc_attr( $option->option_name );
209         echo "
210 <tr>
211         <th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th>
212 <td>";
213         if ( strpos( $value, "\n" ) !== false )
214                 echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . esc_textarea( $value ) . "</textarea>";
215         else
216                 echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
217         echo "</td>
218 </tr>";
219 endforeach;
220 ?>
221   </table>
222
223 <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" />
224
225 <?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?>
226
227   </form>
228 </div>
229
230 <?php
231 include('./admin-footer.php');