diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php
index 3e2e104214..c1ddd09c62 100644
|
a
|
b
|
if ( 'update' === $action ) { // We are saving settings sent from a settings pag |
| 260 | 260 | $options = $allowed_options[ $option_page ]; |
| 261 | 261 | } |
| 262 | 262 | |
| | 263 | $using_locales_default_date_format = false; |
| | 264 | $using_locales_default_time_format = false; |
| 263 | 265 | if ( 'general' === $option_page ) { |
| 264 | 266 | // Handle custom date/time formats. |
| 265 | 267 | if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) |
| 266 | 268 | && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] ) |
| 267 | 269 | ) { |
| 268 | 270 | $_POST['date_format'] = $_POST['date_format_custom']; |
| | 271 | } elseif ( __( 'F j, Y' ) === $_POST['date_format'] ) { |
| | 272 | $using_locales_default_date_format = true; |
| 269 | 273 | } |
| 270 | 274 | |
| 271 | 275 | if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) |
| 272 | 276 | && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] ) |
| 273 | 277 | ) { |
| 274 | 278 | $_POST['time_format'] = $_POST['time_format_custom']; |
| | 279 | } elseif ( __( 'g:i a' ) === $_POST['time_format'] ) { |
| | 280 | $using_locales_default_time_format = true; |
| 275 | 281 | } |
| 276 | 282 | |
| 277 | 283 | // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
| … |
… |
if ( 'update' === $action ) { // We are saving settings sent from a settings pag |
| 348 | 354 | $user_language_new = get_user_locale(); |
| 349 | 355 | if ( $user_language_old !== $user_language_new ) { |
| 350 | 356 | load_default_textdomain( $user_language_new ); |
| | 357 | |
| | 358 | // Set date/time formats to the new locale's defaults if the |
| | 359 | // old locale's defaults were used before the update. |
| | 360 | if ( $using_locales_default_date_format ) { |
| | 361 | update_option( 'date_format', __( 'F j, Y' ) ); |
| | 362 | } |
| | 363 | if ( $using_locales_default_time_format ) { |
| | 364 | update_option( 'time_format', __( 'g:i a' ) ); |
| | 365 | } |
| 351 | 366 | } |
| 352 | 367 | } else { |
| 353 | 368 | add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.' ), 'error' ); |