Make WordPress Core

Ticket #18146: 18146.diff

File 18146.diff, 5.6 KB (added by swissspidy, 9 years ago)

First partial patch

  • src/wp-admin/includes/user.php

    diff --git src/wp-admin/includes/user.php src/wp-admin/includes/user.php
    index 137afcd..7f04b5b 100644
    function edit_user( $user_id = 0 ) { 
    9494                $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
    9595                $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    9696                $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
     97                $user->user_timezone = isset( $_POST['user_timezone'] ) && in_array( $_POST['user_timezone'], timezone_identifiers_list() ) ? sanitize_text_field( $_POST['user_timezone'] ) : '';
    9798        }
    9899
    99100        $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
  • src/wp-admin/user-edit.php

    diff --git src/wp-admin/user-edit.php src/wp-admin/user-edit.php
    index 7274f4d..e1a7977 100644
    if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 
    279279</fieldset>
    280280</td>
    281281</tr>
     282<tr class="user-timezone">
     283    <th scope="row"><?php _e('Timezone')?></th>
     284    <td>
     285        <label for="user_timezone">
     286        <select id="user_timezone" name="user_timezone">
     287            <?php echo wp_timezone_choice( $profileuser->user_timezone, false ); ?>
     288        </select>
     289        <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n( _x('Y-m-d G:i:s', 'timezone date format'), false, 'gmt')); ?></span>
     290        <?php if ( !empty($profileuser->user_timezone) ) : ?>
     291            <span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n( _x('Y-m-d G:i:s', 'timezone date format') )); ?></span>
     292        <?php endif; ?>
     293        <p class="description"><?php _e('Choose a city in the same timezone as you.'); ?></p>
     294    </td>
     295</tr>
    282296<?php
    283297/**
    284298 * Fires at the end of the 'Personal Options' settings table on the user editing screen.
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 6fa978c..d5a1452 100644
    function _wp_timezone_choice_usort_callback( $a, $b ) { 
    34553455 *
    34563456 * @since 2.9.0
    34573457 *
    3458  * @param string $selected_zone Selected Zone
     3458 * @param string $selected_zone Selected Zone.
     3459 * @param bool $manual_offsets Whether to include manual GMT offsets. Defaults to true.
    34593460 * @return string
    34603461 */
    3461 function wp_timezone_choice( $selected_zone ) {
     3462function wp_timezone_choice( $selected_zone, $manual_offsets = true ) {
    34623463        static $mo_loaded = false;
    34633464
    34643465        $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
    function wp_timezone_choice( $selected_zone ) { 
    35553556        $structure[] = '</optgroup>';
    35563557
    35573558        // Do manual UTC offsets
    3558         $structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
    3559         $offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
    3560                 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
    3561         foreach ( $offset_range as $offset ) {
    3562                 if ( 0 <= $offset )
    3563                         $offset_name = '+' . $offset;
    3564                 else
    3565                         $offset_name = (string) $offset;
     3559        if ( true === $manual_offsets ) {
     3560                $structure[] = '<optgroup label="' . esc_attr__('Manual Offsets') . '">';
     3561                $offset_range = array(-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
     3562                        0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
     3563                foreach ($offset_range as $offset) {
     3564                        if (0 <= $offset)
     3565                                $offset_name = '+' . $offset;
     3566                        else
     3567                                $offset_name = (string)$offset;
    35663568
    3567                 $offset_value = $offset_name;
    3568                 $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
    3569                 $offset_name = 'UTC' . $offset_name;
    3570                 $offset_value = 'UTC' . $offset_value;
    3571                 $selected = '';
    3572                 if ( $offset_value === $selected_zone )
    3573                         $selected = 'selected="selected" ';
    3574                 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
     3569                        $offset_value = $offset_name;
     3570                        $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
     3571                        $offset_name = 'UTC' . $offset_name;
     3572                        $offset_value = 'UTC' . $offset_value;
     3573                        $selected = '';
     3574                        if ( $offset_value === $selected_zone )
     3575                                $selected = 'selected="selected" ';
     3576                        $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
    35753577
     3578                }
     3579                $structure[] = '</optgroup>';
    35763580        }
    3577         $structure[] = '</optgroup>';
    35783581
    35793582        return join( "\n", $structure );
    35803583}
  • src/wp-includes/user.php

    diff --git src/wp-includes/user.php src/wp-includes/user.php
    index 453eaa7..2fc86f0 100644
    function wp_create_user($username, $password, $email = '') { 
    18551855 * @return array
    18561856 */
    18571857function _get_additional_user_keys( $user ) {
    1858         $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front' );
     1858        $keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'user_timezone' );
    18591859        return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
    18601860}
    18611861