Make WordPress Core

Ticket #36259: 36259.diff

File 36259.diff, 1.9 KB (added by jornp, 2 years ago)
  • src/wp-admin/options.php

    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 
    260260                $options = $allowed_options[ $option_page ];
    261261        }
    262262
     263        $using_locales_default_date_format = false;
     264        $using_locales_default_time_format = false;
    263265        if ( 'general' === $option_page ) {
    264266                // Handle custom date/time formats.
    265267                if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] )
    266268                        && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] )
    267269                ) {
    268270                        $_POST['date_format'] = $_POST['date_format_custom'];
     271                } elseif ( __( 'F j, Y' ) === $_POST['date_format'] ) {
     272                        $using_locales_default_date_format = true;
    269273                }
    270274
    271275                if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] )
    272276                        && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] )
    273277                ) {
    274278                        $_POST['time_format'] = $_POST['time_format_custom'];
     279                } elseif ( __( 'g:i a' ) === $_POST['time_format'] ) {
     280                        $using_locales_default_time_format = true;
    275281                }
    276282
    277283                // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
    if ( 'update' === $action ) { // We are saving settings sent from a settings pag 
    348354                $user_language_new = get_user_locale();
    349355                if ( $user_language_old !== $user_language_new ) {
    350356                        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                        }
    351366                }
    352367        } else {
    353368                add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.' ), 'error' );