Changeset 42343 for trunk/src/wp-admin/options.php
- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/options.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/options.php
r42228 r42343 19 19 require_once( dirname( __FILE__ ) . '/admin.php' ); 20 20 21 $title = __('Settings');22 $this_file = 'options.php';21 $title = __( 'Settings' ); 22 $this_file = 'options.php'; 23 23 $parent_file = 'options-general.php'; 24 24 25 wp_reset_vars( array('action', 'option_page'));25 wp_reset_vars( array( 'action', 'option_page' ) ); 26 26 27 27 $capability = 'manage_options'; 28 28 29 29 // This is for back compat and will eventually be removed. 30 if ( empty( $option_page) ) {30 if ( empty( $option_page ) ) { 31 31 $option_page = 'options'; 32 32 } else { … … 54 54 55 55 // Handle admin email change requests 56 if ( ! empty( $_GET[ 'adminhash'] ) ) {56 if ( ! empty( $_GET['adminhash'] ) ) { 57 57 $new_admin_details = get_option( 'adminhash' ); 58 $redirect = 'options-general.php?updated=false';59 if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details[ 'hash' ], $_GET[ 'adminhash' ] ) && ! empty( $new_admin_details[ 'newemail'] ) ) {60 update_option( 'admin_email', $new_admin_details[ 'newemail'] );58 $redirect = 'options-general.php?updated=false'; 59 if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details['hash'], $_GET['adminhash'] ) && ! empty( $new_admin_details['newemail'] ) ) { 60 update_option( 'admin_email', $new_admin_details['newemail'] ); 61 61 delete_option( 'adminhash' ); 62 62 delete_option( 'new_admin_email' ); … … 81 81 } 82 82 83 $whitelist_options = array(84 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG', 'new_admin_email' ),83 $whitelist_options = array( 84 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG', 'new_admin_email' ), 85 85 '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' ), 86 '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' ),87 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),88 'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' )86 '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' ), 87 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ), 88 'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' ), 89 89 ); 90 90 $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); 91 91 92 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');93 94 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) 92 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); 93 94 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 95 95 $whitelist_options['reading'][] = 'blog_charset'; 96 } 96 97 97 98 if ( get_site_option( 'initial_db_version' ) < 32453 ) { … … 100 101 } 101 102 102 if ( ! is_multisite() ) {103 if ( ! defined( 'WP_SITEURL' ) )103 if ( ! is_multisite() ) { 104 if ( ! defined( 'WP_SITEURL' ) ) { 104 105 $whitelist_options['general'][] = 'siteurl'; 105 if ( !defined( 'WP_HOME' ) ) 106 } 107 if ( ! defined( 'WP_HOME' ) ) { 106 108 $whitelist_options['general'][] = 'home'; 109 } 107 110 108 111 $whitelist_options['general'][] = 'users_can_register'; 109 112 $whitelist_options['general'][] = 'default_role'; 110 113 111 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);114 $whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options ); 112 115 $whitelist_options['writing'][] = 'ping_sites'; 113 116 … … 115 118 116 119 // If upload_url_path and upload_path are both default values, they're locked. 117 if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) {120 if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) { 118 121 $whitelist_options['media'][] = 'upload_path'; 119 122 $whitelist_options['media'][] = 'upload_url_path'; … … 127 130 * @param bool $enabled Whether post-by-email configuration is enabled. Default true. 128 131 */ 129 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) 130 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); 132 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { 133 $whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options ); 134 } 131 135 } 132 136 … … 144 148 */ 145 149 if ( 'update' == $action ) { 146 if ( 'options' == $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.150 if ( 'options' == $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. 147 151 $unregistered = true; 148 152 check_admin_referer( 'update-options' ); … … 152 156 } 153 157 154 if ( ! isset( $whitelist_options[ $option_page ] ) )158 if ( ! isset( $whitelist_options[ $option_page ] ) ) { 155 159 wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); 160 } 156 161 157 162 if ( 'options' == $option_page ) { … … 159 164 wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); 160 165 } 161 $options = explode( ',', wp_unslash( $_POST[ 'page_options'] ) );166 $options = explode( ',', wp_unslash( $_POST['page_options'] ) ); 162 167 } else { 163 168 $options = $whitelist_options[ $option_page ]; … … 166 171 if ( 'general' == $option_page ) { 167 172 // Handle custom date/time formats. 168 if ( ! empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) )173 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) { 169 174 $_POST['date_format'] = $_POST['date_format_custom']; 170 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) 175 } 176 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) { 171 177 $_POST['time_format'] = $_POST['time_format_custom']; 178 } 172 179 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. 173 if ( ! empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {174 $_POST['gmt_offset'] = $_POST['timezone_string'];175 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);180 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { 181 $_POST['gmt_offset'] = $_POST['timezone_string']; 182 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); 176 183 $_POST['timezone_string'] = ''; 177 184 } … … 193 200 foreach ( $options as $option ) { 194 201 if ( $unregistered ) { 195 _deprecated_argument( 'options.php', '2.7.0', 202 _deprecated_argument( 203 'options.php', '2.7.0', 196 204 sprintf( 197 205 /* translators: %s: the option/setting */ … … 203 211 204 212 $option = trim( $option ); 205 $value = null;213 $value = null; 206 214 if ( isset( $_POST[ $option ] ) ) { 207 215 $value = $_POST[ $option ]; … … 221 229 unset( $GLOBALS['locale'] ); 222 230 $user_language_new = get_user_locale(); 223 if ( $user_language_old !== $user_language_new ) {231 if ( $user_language_old !== $user_language_new ) { 224 232 load_default_textdomain( $user_language_new ); 225 233 } … … 230 238 */ 231 239 // If no settings errors were registered add a general 'updated' message. 232 if ( !count( get_settings_errors() ) ) 233 add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); 234 set_transient('settings_errors', get_settings_errors(), 30); 240 if ( ! count( get_settings_errors() ) ) { 241 add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' ); 242 } 243 set_transient( 'settings_errors', get_settings_errors(), 30 ); 235 244 236 245 /** 237 246 * Redirect back to the settings page that was submitted 238 247 */ 239 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() );248 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); 240 249 wp_redirect( $goback ); 241 250 exit; … … 247 256 <h1><?php esc_html_e( 'All Settings' ); ?></h1> 248 257 <form name="form" action="options.php" method="post" id="all-options"> 249 <?php wp_nonce_field( 'options-options')?>258 <?php wp_nonce_field( 'options-options' ); ?> 250 259 <input type="hidden" name="action" value="update" /> 251 260 <input type="hidden" name="option_page" value="options" /> … … 256 265 foreach ( (array) $options as $option ) : 257 266 $disabled = false; 258 if ( $option->option_name == '' ) 267 if ( $option->option_name == '' ) { 259 268 continue; 269 } 260 270 if ( is_serialized( $option->option_value ) ) { 261 271 if ( is_serialized_string( $option->option_value ) ) { 262 272 // This is a serialized string, so we should display it. 263 $value = maybe_unserialize( $option->option_value );273 $value = maybe_unserialize( $option->option_value ); 264 274 $options_to_update[] = $option->option_name; 265 $class = 'all-options';275 $class = 'all-options'; 266 276 } else { 267 $value = 'SERIALIZED DATA';277 $value = 'SERIALIZED DATA'; 268 278 $disabled = true; 269 $class = 'all-options disabled';279 $class = 'all-options disabled'; 270 280 } 271 281 } else { 272 $value = $option->option_value;282 $value = $option->option_value; 273 283 $options_to_update[] = $option->option_name; 274 $class = 'all-options';284 $class = 'all-options'; 275 285 } 276 286 $name = esc_attr( $option->option_name ); 277 287 ?> 278 288 <tr> 279 <th scope="row"><label for="<?php echo $name ?>"><?php echo esc_html( $option->option_name ); ?></label></th>289 <th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th> 280 290 <td> 281 291 <?php if ( strpos( $value, "\n" ) !== false ) : ?> 282 <textarea class="<?php echo $class ?>" name="<?php echo $name ?>" id="<?php echo $name ?>" cols="30" rows="5"><?php 283 echo esc_textarea( $value ); 284 ?></textarea> 285 <?php else: ?> 286 <input class="regular-text <?php echo $class ?>" type="text" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>"<?php disabled( $disabled, true ) ?> /> 292 <textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"> 293 <?php 294 echo esc_textarea( $value ); 295 ?> 296 </textarea> 297 <?php else : ?> 298 <input class="regular-text <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>"<?php disabled( $disabled, true ); ?> /> 287 299 <?php endif ?></td> 288 300 </tr>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)