Ticket #6913: time_format_6913_rev2.diff
| File time_format_6913_rev2.diff, 10.3 kB (added by regulatethis, 7 months ago) |
|---|
-
wp-admin/includes/post.php
old new 81 81 } 82 82 } 83 83 84 // Let's handle the conversion to 24 hour time if the user has chosen 12 hour for posting 85 if( !empty( $_POST['editor_time_format'] ) && $_POST['editor_time_format'] == '12_hour' ) { 86 // If only the meridiem has been switched, we still need to update the time... 87 if( !empty( $_POST['hidden_meridiem'] ) && $_POST['hidden_meridiem'] != $_POST['meridiem'] ) 88 $_POST['edit_date'] = '1'; 89 90 // "Convert" hour back to 24-hour format if necessary, taking the meridiem into account... 91 if ( !empty( $_POST['editor_time_format'] ) && $_POST['editor_time_format'] == '12_hour' ) { 92 93 // Do the conversion... 94 $_POST['hh'] = $_POST['hh'] < 12 ? $_POST['hh'] : $_POST['hh'] - 12; 95 96 if ( $_POST['meridiem'] == 'pm' ) { 97 $_POST['hh'] += 12; 98 } 99 } 100 } 101 84 102 if (!empty ( $_POST['edit_date'] ) ) { 85 103 $aa = $_POST['aa']; 86 104 $mm = $_POST['mm']; -
wp-admin/includes/schema.php
old new 185 185 add_option('what_to_show', 'posts'); 186 186 add_option('date_format', __('F j, Y')); 187 187 add_option('time_format', __('g:i a')); 188 add_option('g_editor_time_format', '24_hour'); 188 189 add_option('links_updated_date_format', __('F j, Y g:i a')); 189 190 add_option('links_recently_updated_prepend', '<em>'); 190 191 add_option('links_recently_updated_append', '</em>'); -
wp-admin/includes/template.php
old new 844 844 845 845 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); 846 846 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 847 848 $time_format = get_user_option('editor_time_format'); 849 if ( empty($time_format) || $time_format == 'default') 850 $time_format = get_option('g_editor_time_format'); 851 852 $hour_format = $time_format == '12_hour' ? 'g' : 'H'; 853 847 854 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj ); 848 855 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj ); 849 856 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj ); 850 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );857 $hh = ($edit) ? mysql2date( $hour_format, $post_date ) : gmdate( $hour_format, $time_adj ); 851 858 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); 852 859 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); 853 860 861 if( '12_hour' == $time_format ) { 862 $meridiem = ($edit) ? date( 'a', strtotime($post_date) ) : date( 'a' ); 863 $locale_meridiem = ($edit) ? $wp_locale->get_meridiem( date( 'A', strtotime($post_date) ) ) : $wp_locale->get_meridiem( date( 'A' ) ); 864 $locale_am = $wp_locale->get_meridiem( 'AM' ); 865 $locale_pm = $wp_locale->get_meridiem( 'PM' ); 866 } 854 867 $month = "<select id=\"mm\" name=\"mm\"$tab_index_attribute>\n"; 855 868 for ( $i = 1; $i < 13; $i = $i +1 ) { 856 869 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"'; … … 864 877 $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />'; 865 878 $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 866 879 $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />'; 880 881 if( '12_hour' == $time_format ) { 882 $am_selected = $meridiem == 'am' ? 'selected="selected"' : ''; 883 $pm_selected = $meridiem == 'pm' ? 'selected="selected"' : ''; 884 885 $meridiem_drop_down = '<select name="meridiem" id="meridiem"' . $tab_index_attribute . '>' . PHP_EOL; 886 $meridiem_drop_down .= ' <option value="am" ' . $am_selected . '>' . $locale_am . '</option>' . PHP_EOL; 887 $meridiem_drop_down .= ' <option value="pm" ' . $pm_selected . '>' . $locale_pm . '</option>' . PHP_EOL; 888 $meridiem_drop_down .= '</selected>' . PHP_EOL; 889 } 890 867 891 printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute); 892 893 if ( '12_hour' == $time_format ) 894 echo $meridiem_drop_down; 895 868 896 echo "\n\n"; 869 897 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) 870 898 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; 899 900 if( '12_hour' == $time_format ) 901 echo '<input type="hidden" id="hidden_meridiem" name="hidden_meridiem" value="' . $meridiem . '" />'; 902 871 903 ?> 872 904 873 905 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> 906 <input type="hidden" id="editor_time_format" name="editor_time_format" value="<?php echo $time_format; ?>" /> 874 907 <?php 875 908 } 876 909 -
wp-admin/includes/user.php
old new 80 80 else 81 81 $user->admin_color = 'fresh'; 82 82 83 if ( !update ) { 84 $user->editor_time_format = 'default'; // Default to global setting for new users. 85 } else if ( isset( $_POST['editor_time_format'] ) ) { 86 echo $_POST['editor_time_format']; 87 exit; 88 $user->editor_time_format = $_POST['editor_time_format']; 89 } else { 90 $user->editor_time_format = 'default'; 91 } 92 83 93 $errors = new WP_Error(); 84 94 85 95 /* checking that username has been typed */ -
wp-admin/options-general.php
old new 98 98 <?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') ?></td> 99 99 </tr> 100 100 <tr> 101 <th scope="row"><?php _e('Editor Time Format') ?></th> 102 <td> 103 <?php 104 $current_time_format = get_option('g_editor_time_format'); 105 if ( empty($current_time_format) ) 106 $current_time_format = '24_hour'; 107 ?> 108 <label for="g_editor_time_format_12"><input name="g_editor_time_format" id="g_editor_time_format_12" type="radio" value="12_hour" <?php checked('12_hour', $current_time_format);?> /> 12-hour <i>2:35pm</i></label><br /> 109 <label for="g_editor_time_format_24"><input name="g_editor_time_format" id="g_editor_time_format_24" type="radio" value="24_hour" <?php checked('24_hour', $current_time_format);?> /> 24-hour <i>14:35</i></label><br /> 110 </tr> 111 <tr> 101 112 <th scope="row"><?php _e('Week Starts On') ?></th> 102 113 <td><select name="start_of_week" id="start_of_week"> 103 114 <?php … … 112 123 113 124 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" /> 114 125 <input type="hidden" name="action" value="update" /> 115 <input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format, start_of_week,comment_registration,default_role" />126 <input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format,g_editor_time_format,start_of_week,comment_registration,default_role" /> 116 127 </p> 117 128 </form> 118 129 -
wp-admin/user-edit.php
old new 161 161 </tr> 162 162 <?php endif; ?> 163 163 <tr> 164 <th scope="row"><?php _e('Editor Time Format')?></th> 165 <td> 166 <?php 167 $default_time_format = get_option('g_editor_time_format'); 168 $default_time_format = $default_time_format == '24_hour' ? '24-hour' : '12-hour'; 169 170 $current_time_format = get_user_option('editor_time_format', $user_id); 171 if ( empty($current_time_format) ) 172 $current_time_format = 'default'; 173 ?> 174 <label for="editor_time_format_default"><input name="editor_time_format" id="editor_time_format_default" type="radio" value="default" <?php checked('default', $current_time_format);?> /> Default <i>Use global setting (<?php echo $default_time_format; ?>)</i></label><br /> 175 <label for="editor_time_format_12"><input name="editor_time_format" id="editor_time_format_12" type="radio" value="12_hour" <?php checked('12_hour', $current_time_format);?> /> 12-hour <i>2:35pm</i></label><br /> 176 <label for="editor_time_format_24"><input name="editor_time_format" id="editor_time_format_24" type="radio" value="24_hour" <?php checked('24_hour', $current_time_format);?> /> 24-hour <i>14:35</i></label><br /> 177 </td> 178 </tr> 179 <tr> 164 180 <th scope="row"><?php _e('Admin Color Scheme')?></th> 165 181 <td> 166 182 <?php -
wp-includes/registration.php
old new 91 91 * 'jabber' - User's Jabber account. 92 92 * 'aim' - User's AOL IM account. 93 93 * 'yim' - User's Yahoo IM account. 94 * 'editor_time_format' - A string used to set the user's chosen time format for the editor (12_hour or 24_hour) 94 95 * 95 96 * @since 2.0.0 96 97 * @uses $wpdb WordPress database layer. … … 157 158 if ( empty($admin_color) ) 158 159 $admin_color = 'fresh'; 159 160 $admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color); 160 161 162 if ( empty($editor_time_format) ) { 163 $editor_time_format = 'default'; 164 } else { 165 if ( $editor_time_format != '12_hour' && $editor_time_format != '24_hour' ) { 166 $editor_time_format = 'default'; 167 } 168 } 169 161 170 if ( empty($user_registered) ) 162 171 $user_registered = gmdate('Y-m-d H:i:s'); 163 172 … … 181 190 update_usermeta( $user_id, 'yim', $yim ); 182 191 update_usermeta( $user_id, 'rich_editing', $rich_editing); 183 192 update_usermeta( $user_id, 'admin_color', $admin_color); 193 update_usermeta( $user_id, 'editor_time_format', $editor_time_format); 184 194 185 195 if ( $update && isset($role) ) { 186 196 $user = new WP_User($user_id);
