changeset 5 | 5e2f62d02dcd |
parent 0 | d970ebf37754 |
child 7 | cf61fcea0001 |
4:346c88efed21 | 5:5e2f62d02dcd |
---|---|
24 |
24 |
25 wp_reset_vars(array('action', 'option_page')); |
25 wp_reset_vars(array('action', 'option_page')); |
26 |
26 |
27 $capability = 'manage_options'; |
27 $capability = 'manage_options'; |
28 |
28 |
29 if ( empty($option_page) ) // This is for back compat and will eventually be removed. |
29 // This is for back compat and will eventually be removed. |
30 if ( empty($option_page) ) { |
|
30 $option_page = 'options'; |
31 $option_page = 'options'; |
31 else |
32 } else { |
32 |
33 |
33 /** |
34 /** |
34 * Filter the capability required when using the Settings API. |
35 * Filter the capability required when using the Settings API. |
35 * |
36 * |
36 * By default, the options groups for all registered settings require the manage_options capability. |
37 * By default, the options groups for all registered settings require the manage_options capability. |
39 * @since 3.2.0 |
40 * @since 3.2.0 |
40 * |
41 * |
41 * @param string $capability The capability used for the page, which is manage_options by default. |
42 * @param string $capability The capability used for the page, which is manage_options by default. |
42 */ |
43 */ |
43 $capability = apply_filters( "option_page_capability_{$option_page}", $capability ); |
44 $capability = apply_filters( "option_page_capability_{$option_page}", $capability ); |
45 } |
|
44 |
46 |
45 if ( !current_user_can( $capability ) ) |
47 if ( !current_user_can( $capability ) ) |
46 wp_die(__('Cheatin’ uh?')); |
48 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
47 |
49 |
48 // Handle admin email change requests |
50 // Handle admin email change requests |
49 if ( is_multisite() ) { |
51 if ( is_multisite() ) { |
50 if ( ! empty($_GET[ 'adminhash' ] ) ) { |
52 if ( ! empty($_GET[ 'adminhash' ] ) ) { |
51 $new_admin_details = get_option( 'adminhash' ); |
53 $new_admin_details = get_option( 'adminhash' ); |
65 exit; |
67 exit; |
66 } |
68 } |
67 } |
69 } |
68 |
70 |
69 if ( is_multisite() && !is_super_admin() && 'update' != $action ) |
71 if ( is_multisite() && !is_super_admin() && 'update' != $action ) |
70 wp_die(__('Cheatin’ uh?')); |
72 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
71 |
73 |
72 $whitelist_options = array( |
74 $whitelist_options = array( |
73 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ), |
75 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ), |
74 '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' ), |
76 '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' ), |
75 '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' ), |
77 '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' ), |
76 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ), |
78 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ), |
77 'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' ) |
79 'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' ) |
78 ); |
80 ); |
103 $whitelist_options['media'][] = 'upload_path'; |
105 $whitelist_options['media'][] = 'upload_path'; |
104 $whitelist_options['media'][] = 'upload_url_path'; |
106 $whitelist_options['media'][] = 'upload_url_path'; |
105 } |
107 } |
106 } else { |
108 } else { |
107 $whitelist_options['general'][] = 'new_admin_email'; |
109 $whitelist_options['general'][] = 'new_admin_email'; |
108 $whitelist_options['general'][] = 'WPLANG'; |
110 |
109 |
111 /** |
110 /** |
112 * Filter whether the post-by-email functionality is enabled. |
111 * Toggle post-by-email functionality. |
|
112 * |
113 * |
113 * @since 3.0.0 |
114 * @since 3.0.0 |
114 * |
115 * |
115 * @param bool True or false, based on whether post-by-email configuration is enabled or not. |
116 * @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
116 */ |
117 */ |
117 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
118 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
118 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
119 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
119 } |
120 } |
120 |
121 |
148 $options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) ); |
149 $options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) ); |
149 } else { |
150 } else { |
150 $options = $whitelist_options[ $option_page ]; |
151 $options = $whitelist_options[ $option_page ]; |
151 } |
152 } |
152 |
153 |
153 // Handle custom date/time formats |
|
154 if ( 'general' == $option_page ) { |
154 if ( 'general' == $option_page ) { |
155 // Handle custom date/time formats. |
|
155 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) |
156 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) |
156 $_POST['date_format'] = $_POST['date_format_custom']; |
157 $_POST['date_format'] = $_POST['date_format_custom']; |
157 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) |
158 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) |
158 $_POST['time_format'] = $_POST['time_format_custom']; |
159 $_POST['time_format'] = $_POST['time_format_custom']; |
159 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
160 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
160 if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
161 if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
161 $_POST['gmt_offset'] = $_POST['timezone_string']; |
162 $_POST['gmt_offset'] = $_POST['timezone_string']; |
162 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); |
163 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); |
163 $_POST['timezone_string'] = ''; |
164 $_POST['timezone_string'] = ''; |
164 } |
165 } |
166 |
|
167 // Handle translation install. |
|
168 if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed |
|
169 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
170 |
|
171 if ( wp_can_install_language_pack() ) { |
|
172 $language = wp_download_language_pack( $_POST['WPLANG'] ); |
|
173 if ( $language ) { |
|
174 $_POST['WPLANG'] = $language; |
|
175 } |
|
176 } |
|
177 } |
|
165 } |
178 } |
166 |
179 |
167 if ( $options ) { |
180 if ( $options ) { |
168 foreach ( $options as $option ) { |
181 foreach ( $options as $option ) { |
169 if ( $unregistered ) |
182 if ( $unregistered ) |
170 _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 ) ); |
183 _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See https://codex.wordpress.org/Settings_API' ), $option, $option_page ) ); |
171 |
184 |
172 $option = trim( $option ); |
185 $option = trim( $option ); |
173 $value = null; |
186 $value = null; |
174 if ( isset( $_POST[ $option ] ) ) { |
187 if ( isset( $_POST[ $option ] ) ) { |
175 $value = $_POST[ $option ]; |
188 $value = $_POST[ $option ]; |
177 $value = trim( $value ); |
190 $value = trim( $value ); |
178 $value = wp_unslash( $value ); |
191 $value = wp_unslash( $value ); |
179 } |
192 } |
180 update_option( $option, $value ); |
193 update_option( $option, $value ); |
181 } |
194 } |
195 |
|
196 // Switch translation in case WPLANG was changed. |
|
197 $language = get_option( 'WPLANG' ); |
|
198 if ( $language ) { |
|
199 load_default_textdomain( $language ); |
|
200 } else { |
|
201 unload_textdomain( 'default' ); |
|
202 } |
|
182 } |
203 } |
183 |
204 |
184 /** |
205 /** |
185 * Handle settings errors and return to options page |
206 * Handle settings errors and return to options page |
186 */ |
207 */ |
198 } |
219 } |
199 |
220 |
200 include( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
221 include( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
201 |
222 |
202 <div class="wrap"> |
223 <div class="wrap"> |
203 <?php screen_icon(); ?> |
|
204 <h2><?php esc_html_e('All Settings'); ?></h2> |
224 <h2><?php esc_html_e('All Settings'); ?></h2> |
205 <form name="form" action="options.php" method="post" id="all-options"> |
225 <form name="form" action="options.php" method="post" id="all-options"> |
206 <?php wp_nonce_field('options-options') ?> |
226 <?php wp_nonce_field('options-options') ?> |
207 <input type="hidden" name="action" value="update" /> |
227 <input type="hidden" name="action" value="update" /> |
208 <input type='hidden' name='option_page' value='options' /> |
228 <input type="hidden" name="option_page" value="options" /> |
209 <table class="form-table"> |
229 <table class="form-table"> |
210 <?php |
230 <?php |
211 $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
231 $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
212 |
232 |
213 foreach ( (array) $options as $option ) : |
233 foreach ( (array) $options as $option ) : |
214 $disabled = false; |
234 $disabled = false; |
215 if ( $option->option_name == '' ) |
235 if ( $option->option_name == '' ) |
216 continue; |
236 continue; |
217 if ( is_serialized( $option->option_value ) ) { |
237 if ( is_serialized( $option->option_value ) ) { |
218 if ( is_serialized_string( $option->option_value ) ) { |
238 if ( is_serialized_string( $option->option_value ) ) { |
219 // this is a serialized string, so we should display it |
239 // This is a serialized string, so we should display it. |
220 $value = maybe_unserialize( $option->option_value ); |
240 $value = maybe_unserialize( $option->option_value ); |
221 $options_to_update[] = $option->option_name; |
241 $options_to_update[] = $option->option_name; |
222 $class = 'all-options'; |
242 $class = 'all-options'; |
223 } else { |
243 } else { |
224 $value = 'SERIALIZED DATA'; |
244 $value = 'SERIALIZED DATA'; |
229 $value = $option->option_value; |
249 $value = $option->option_value; |
230 $options_to_update[] = $option->option_name; |
250 $options_to_update[] = $option->option_name; |
231 $class = 'all-options'; |
251 $class = 'all-options'; |
232 } |
252 } |
233 $name = esc_attr( $option->option_name ); |
253 $name = esc_attr( $option->option_name ); |
234 echo " |
254 ?> |
235 <tr> |
255 <tr> |
236 <th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th> |
256 <th scope="row"><label for="<?php echo $name ?>"><?php echo esc_html( $option->option_name ); ?></label></th> |
237 <td>"; |
257 <td> |
238 if ( strpos( $value, "\n" ) !== false ) |
258 <?php if ( strpos( $value, "\n" ) !== false ) : ?> |
239 echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . esc_textarea( $value ) . "</textarea>"; |
259 <textarea class="<?php echo $class ?>" name="<?php echo $name ?>" id="<?php echo $name ?>" cols="30" rows="5"><?php |
240 else |
260 echo esc_textarea( $value ); |
241 echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />"; |
261 ?></textarea> |
242 echo "</td> |
262 <?php else: ?> |
243 </tr>"; |
263 <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 ) ?> /> |
244 endforeach; |
264 <?php endif ?></td> |
245 ?> |
265 </tr> |
266 <?php endforeach; ?> |
|
246 </table> |
267 </table> |
247 |
268 |
248 <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /> |
269 <input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /> |
249 |
270 |
250 <?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?> |
271 <?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?> |