author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:06:33 +0200 | |
changeset 8 | c7c34916027a |
parent 7 | cf61fcea0001 |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 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( dirname( __FILE__ ) . '/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 |
||
5 | 29 |
// This is for back compat and will eventually be removed. |
30 |
if ( empty($option_page) ) { |
|
0 | 31 |
$option_page = 'options'; |
5 | 32 |
} else { |
0 | 33 |
|
34 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* Filters the capability required when using the Settings API. |
0 | 36 |
* |
37 |
* By default, the options groups for all registered settings require the manage_options capability. |
|
38 |
* This filter is required to change the capability required for a certain options page. |
|
39 |
* |
|
40 |
* @since 3.2.0 |
|
41 |
* |
|
42 |
* @param string $capability The capability used for the page, which is manage_options by default. |
|
43 |
*/ |
|
44 |
$capability = apply_filters( "option_page_capability_{$option_page}", $capability ); |
|
5 | 45 |
} |
0 | 46 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
if ( ! current_user_can( $capability ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
'<p>' . __( 'Sorry, you are not allowed to manage these options.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
403 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
} |
0 | 54 |
|
55 |
// Handle admin email change requests |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
if ( ! empty( $_GET[ 'adminhash' ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
$new_admin_details = get_option( 'adminhash' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
$redirect = 'options-general.php?updated=false'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details[ 'hash' ], $_GET[ 'adminhash' ] ) && ! empty( $new_admin_details[ 'newemail' ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
update_option( 'admin_email', $new_admin_details[ 'newemail' ] ); |
0 | 61 |
delete_option( 'adminhash' ); |
62 |
delete_option( 'new_admin_email' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
$redirect = 'options-general.php?updated=true'; |
0 | 64 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
wp_redirect( admin_url( $redirect ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
exit; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
} elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
check_admin_referer( 'dismiss-' . get_current_blog_id() . '-new_admin_email' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
delete_option( 'adminhash' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
delete_option( 'new_admin_email' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
wp_redirect( admin_url( 'options-general.php?updated=true' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
exit; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
if ( is_multisite() && ! current_user_can( 'manage_network_options' ) && 'update' != $action ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
'<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
403 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
); |
0 | 81 |
} |
82 |
||
83 |
$whitelist_options = array( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
'general' => array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
'blogname', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
'blogdescription', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
'gmt_offset', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
'date_format', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
'time_format', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
'start_of_week', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
'timezone_string', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
'WPLANG', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
'new_admin_email', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
'discussion' => array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
'default_pingback_flag', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
'default_ping_status', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
'default_comment_status', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
'comments_notify', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
'moderation_notify', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
'comment_moderation', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
'require_name_email', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
'comment_whitelist', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
'comment_max_links', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
'moderation_keys', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
'blacklist_keys', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
'show_avatars', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
'avatar_rating', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
'avatar_default', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
'close_comments_for_old_posts', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
'close_comments_days_old', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
'thread_comments', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
'thread_comments_depth', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
'page_comments', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
'comments_per_page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
'default_comments_page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
'comment_order', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
'comment_registration', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
'show_comments_cookies_opt_in', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
'media' => array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
'thumbnail_size_w', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
'thumbnail_size_h', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
'thumbnail_crop', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
'medium_size_w', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
'medium_size_h', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
'large_size_w', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
'large_size_h', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
'image_default_size', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
'image_default_align', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
'image_default_link_type', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
'reading' => array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
'posts_per_page', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
'posts_per_rss', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
'rss_use_excerpt', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
'show_on_front', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
'page_on_front', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
'page_for_posts', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
'blog_public', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
'writing' => array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
'default_category', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
'default_email_category', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
'default_link_category', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
'default_post_format', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
), |
0 | 148 |
); |
149 |
$whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); |
|
150 |
||
151 |
$mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); |
|
152 |
||
153 |
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) |
|
154 |
$whitelist_options['reading'][] = 'blog_charset'; |
|
155 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
$whitelist_options['writing'][] = 'use_smilies'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
$whitelist_options['writing'][] = 'use_balanceTags'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
|
0 | 161 |
if ( !is_multisite() ) { |
162 |
if ( !defined( 'WP_SITEURL' ) ) |
|
163 |
$whitelist_options['general'][] = 'siteurl'; |
|
164 |
if ( !defined( 'WP_HOME' ) ) |
|
165 |
$whitelist_options['general'][] = 'home'; |
|
166 |
||
167 |
$whitelist_options['general'][] = 'users_can_register'; |
|
168 |
$whitelist_options['general'][] = 'default_role'; |
|
169 |
||
170 |
$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
|
171 |
$whitelist_options['writing'][] = 'ping_sites'; |
|
172 |
||
173 |
$whitelist_options['media'][] = 'uploads_use_yearmonth_folders'; |
|
174 |
||
175 |
// If upload_url_path and upload_path are both default values, they're locked. |
|
176 |
if ( get_option( 'upload_url_path' ) || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) { |
|
177 |
$whitelist_options['media'][] = 'upload_path'; |
|
178 |
$whitelist_options['media'][] = 'upload_url_path'; |
|
179 |
} |
|
180 |
} else { |
|
181 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
* Filters whether the post-by-email functionality is enabled. |
0 | 183 |
* |
184 |
* @since 3.0.0 |
|
185 |
* |
|
5 | 186 |
* @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
0 | 187 |
*/ |
188 |
if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
|
189 |
$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
|
190 |
} |
|
191 |
||
192 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
* Filters the options white list. |
0 | 194 |
* |
195 |
* @since 2.7.0 |
|
196 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* @param array $whitelist_options White list options. |
0 | 198 |
*/ |
199 |
$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); |
|
200 |
||
201 |
/* |
|
202 |
* If $_GET['action'] == 'update' we are saving settings sent from a settings page |
|
203 |
*/ |
|
204 |
if ( 'update' == $action ) { |
|
205 |
if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. |
|
206 |
$unregistered = true; |
|
207 |
check_admin_referer( 'update-options' ); |
|
208 |
} else { |
|
209 |
$unregistered = false; |
|
210 |
check_admin_referer( $option_page . '-options' ); |
|
211 |
} |
|
212 |
||
213 |
if ( !isset( $whitelist_options[ $option_page ] ) ) |
|
214 |
wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); |
|
215 |
||
216 |
if ( 'options' == $option_page ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
} |
0 | 220 |
$options = explode( ',', wp_unslash( $_POST[ 'page_options' ] ) ); |
221 |
} else { |
|
222 |
$options = $whitelist_options[ $option_page ]; |
|
223 |
} |
|
224 |
||
225 |
if ( 'general' == $option_page ) { |
|
5 | 226 |
// Handle custom date/time formats. |
0 | 227 |
if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) |
228 |
$_POST['date_format'] = $_POST['date_format_custom']; |
|
229 |
if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) |
|
230 |
$_POST['time_format'] = $_POST['time_format_custom']; |
|
231 |
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
|
232 |
if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
|
233 |
$_POST['gmt_offset'] = $_POST['timezone_string']; |
|
234 |
$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); |
|
235 |
$_POST['timezone_string'] = ''; |
|
236 |
} |
|
5 | 237 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
// Handle translation installation. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) { |
5 | 240 |
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
241 |
||
242 |
if ( wp_can_install_language_pack() ) { |
|
243 |
$language = wp_download_language_pack( $_POST['WPLANG'] ); |
|
244 |
if ( $language ) { |
|
245 |
$_POST['WPLANG'] = $language; |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
0 | 249 |
} |
250 |
||
251 |
if ( $options ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
$user_language_old = get_user_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
|
0 | 254 |
foreach ( $options as $option ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
if ( $unregistered ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
_deprecated_argument( 'options.php', '2.7.0', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
/* translators: %s: the option/setting */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
__( 'The %s setting is unregistered. Unregistered settings are deprecated. See https://codex.wordpress.org/Settings_API' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
'<code>' . $option . '</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
} |
0 | 264 |
|
265 |
$option = trim( $option ); |
|
266 |
$value = null; |
|
267 |
if ( isset( $_POST[ $option ] ) ) { |
|
268 |
$value = $_POST[ $option ]; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
if ( ! is_array( $value ) ) { |
0 | 270 |
$value = trim( $value ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
} |
0 | 272 |
$value = wp_unslash( $value ); |
273 |
} |
|
274 |
update_option( $option, $value ); |
|
275 |
} |
|
5 | 276 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
* Switch translation in case WPLANG was changed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
* The global $locale is used in get_locale() which is |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
* used as a fallback in get_user_locale(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
unset( $GLOBALS['locale'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
$user_language_new = get_user_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
if ( $user_language_old !== $user_language_new ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
load_default_textdomain( $user_language_new ); |
5 | 286 |
} |
0 | 287 |
} |
288 |
||
289 |
/** |
|
290 |
* Handle settings errors and return to options page |
|
291 |
*/ |
|
292 |
// If no settings errors were registered add a general 'updated' message. |
|
293 |
if ( !count( get_settings_errors() ) ) |
|
294 |
add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); |
|
295 |
set_transient('settings_errors', get_settings_errors(), 30); |
|
296 |
||
297 |
/** |
|
298 |
* Redirect back to the settings page that was submitted |
|
299 |
*/ |
|
300 |
$goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
|
301 |
wp_redirect( $goback ); |
|
302 |
exit; |
|
303 |
} |
|
304 |
||
305 |
include( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
|
306 |
||
307 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
<h1><?php esc_html_e( 'All Settings' ); ?></h1> |
0 | 309 |
<form name="form" action="options.php" method="post" id="all-options"> |
310 |
<?php wp_nonce_field('options-options') ?> |
|
311 |
<input type="hidden" name="action" value="update" /> |
|
5 | 312 |
<input type="hidden" name="option_page" value="options" /> |
0 | 313 |
<table class="form-table"> |
314 |
<?php |
|
315 |
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
|
316 |
||
317 |
foreach ( (array) $options as $option ) : |
|
318 |
$disabled = false; |
|
319 |
if ( $option->option_name == '' ) |
|
320 |
continue; |
|
321 |
if ( is_serialized( $option->option_value ) ) { |
|
322 |
if ( is_serialized_string( $option->option_value ) ) { |
|
5 | 323 |
// This is a serialized string, so we should display it. |
0 | 324 |
$value = maybe_unserialize( $option->option_value ); |
325 |
$options_to_update[] = $option->option_name; |
|
326 |
$class = 'all-options'; |
|
327 |
} else { |
|
328 |
$value = 'SERIALIZED DATA'; |
|
329 |
$disabled = true; |
|
330 |
$class = 'all-options disabled'; |
|
331 |
} |
|
332 |
} else { |
|
333 |
$value = $option->option_value; |
|
334 |
$options_to_update[] = $option->option_name; |
|
335 |
$class = 'all-options'; |
|
336 |
} |
|
337 |
$name = esc_attr( $option->option_name ); |
|
5 | 338 |
?> |
0 | 339 |
<tr> |
5 | 340 |
<th scope="row"><label for="<?php echo $name ?>"><?php echo esc_html( $option->option_name ); ?></label></th> |
341 |
<td> |
|
342 |
<?php if ( strpos( $value, "\n" ) !== false ) : ?> |
|
343 |
<textarea class="<?php echo $class ?>" name="<?php echo $name ?>" id="<?php echo $name ?>" cols="30" rows="5"><?php |
|
344 |
echo esc_textarea( $value ); |
|
345 |
?></textarea> |
|
346 |
<?php else: ?> |
|
347 |
<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 ) ?> /> |
|
348 |
<?php endif ?></td> |
|
349 |
</tr> |
|
350 |
<?php endforeach; ?> |
|
0 | 351 |
</table> |
352 |
||
353 |
<input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /> |
|
354 |
||
355 |
<?php submit_button( __( 'Save Changes' ), 'primary', 'Update' ); ?> |
|
356 |
||
357 |
</form> |
|
358 |
</div> |
|
359 |
||
360 |
<?php |
|
361 |
include( ABSPATH . 'wp-admin/admin-footer.php' ); |