Ticket #3962: 3962.diff
File 3962.diff, 6.6 KB (added by , 16 years ago) |
---|
-
wp-admin/options-general.php
93 93 </td> 94 94 </tr> 95 95 <tr> 96 <?php 97 if (!wp_timezone_supported()) : // no magic timezone support here 98 ?> 96 99 <th scope="row"><label for="gmt_offset"><?php _e('Timezone') ?> </label></th> 97 100 <td> 98 101 <select name="gmt_offset" id="gmt_offset"> … … 127 130 <br/> 128 131 <span class="setting-description"><?php _e('Unfortunately, you have to manually update this for Daylight Savings Time. Lame, we know, but will be fixed in the future.'); ?></span> 129 132 </td> 133 <?php 134 else: // looks like we can do nice timezone selection! 135 $current_offset = get_option('gmt_offset'); 136 ?> 137 <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th> 138 <td> 139 140 <select id="timezone_string" name="timezone_string"> 141 <?php echo wp_timezone_choice(get_option('timezone_string')); ?> 142 </select> 143 144 <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n(__('Y-m-d G:i:s'), false, 'gmt')); ?></span> 145 <?php if (get_option('timezone_string')) : ?> 146 <span id="local-time"><?php printf(__('Current time in %1$s is <code>%2$s</code>'), get_option('timezone_string'), date_i18n(__('Y-m-d G:i:s'))); ?></span> 147 <?php endif; ?> 148 <br/> 149 <span class="setting-description"><?php _e('Choose a city in the same timezone as you.'); ?></span> 150 </td> 151 152 <?php endif; ?> 130 153 </tr> 131 154 <tr> 132 155 <th scope="row"><?php _e('Date Format') ?></th> -
wp-admin/options.php
22 22 wp_reset_vars(array('action')); 23 23 24 24 $whitelist_options = array( 25 'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'default_role' ),25 'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'default_role', 'timezone_string' ), 26 26 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), 27 27 'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path' ), 28 28 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ), -
wp-includes/default-filters.php
203 203 add_action('edit_form_advanced', 'wp_remember_old_slug'); 204 204 add_action('init', '_show_post_preview'); 205 205 206 add_filter('pre_option_gmt_offset','wp_timezone_override_offset'); 207 206 208 ?> -
wp-includes/functions.php
2902 2902 return $can_clone ? clone( $object ) : $object; 2903 2903 } 2904 2904 2905 /** 2906 * gmt_offset modification for smart timezone handling 2907 * 2908 * Overrides the gmt_offset option if we have a timezone_string available 2909 */ 2910 function wp_timezone_override_offset() { 2911 if (!wp_timezone_supported()) return false; 2905 2912 2906 ?> 2913 $tz = get_option('timezone_string'); 2914 if (empty($tz)) return false; 2915 2916 @date_default_timezone_set($tz); 2917 2918 $dateTimeZoneSelected = timezone_open($tz); 2919 $dateTimeServer = date_create(); 2920 if ($dateTimeZoneSelected === false || $dateTimeServer === false) return false; 2921 2922 $timeOffset = timezone_offset_get($dateTimeZoneSelected, $dateTimeServer); 2923 $timeOffset = $timeOffset / 3600; 2924 2925 return $timeOffset; 2926 } 2927 2928 /** 2929 * Check for PHP timezone support 2930 * 2931 */ 2932 function wp_timezone_supported() { 2933 if (function_exists('date_default_timezone_set') 2934 && function_exists('timezone_identifiers_list') 2935 && function_exists('timezone_open') 2936 && function_exists('timezone_offset_get') 2937 ) 2938 return true; 2939 2940 return false; 2941 } 2942 2943 /** 2944 * Gives a nicely formatted list of timezone strings // temporary! Not in final 2945 * 2946 * @param string $selectedzone - which zone should be the selected one 2947 * 2948 */ 2949 function wp_timezone_choice($selectedzone) { 2950 $all = timezone_identifiers_list(); 2951 2952 $i = 0; 2953 foreach($all AS $zone) { 2954 $zone = explode('/',$zone); 2955 $zonen[$i]['continent'] = isset($zone[0]) ? $zone[0] : ''; 2956 $zonen[$i]['city'] = isset($zone[1]) ? $zone[1] : ''; 2957 $zonen[$i]['subcity'] = isset($zone[2]) ? $zone[2] : ''; 2958 $i++; 2959 } 2960 2961 asort($zonen); 2962 $structure = ''; 2963 foreach($zonen AS $zone) { 2964 extract($zone); 2965 if($continent == 'Africa' || $continent == 'America' || $continent == 'Antarctica' || $continent == 'Arctic' || $continent == 'Asia' || $continent == 'Atlantic' || $continent == 'Australia' || $continent == 'Europe' || $continent == 'Indian' || $continent == 'Pacific') { 2966 if(!isset($selectcontinent)) { 2967 $structure .= '<optgroup label="'.$continent.'">'; // continent 2968 } elseif($selectcontinent != $continent) { 2969 $structure .= '</optgroup><optgroup label="'.$continent.'">'; // continent 2970 } 2971 2972 if(isset($city) != ''){ 2973 if (!empty($subcity) != ''){ 2974 $city = $city . '/'. $subcity; 2975 } 2976 $structure .= "<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected "':'')." value=\"".($continent.'/'.$city)."\">".str_replace('_',' ',$city)."</option>"; //Timezone 2977 } else { 2978 if (!empty($subcity) != ''){ 2979 $city = $city . '/'. $subcity; 2980 } 2981 $structure .= "<option ".(($continent==$selectedzone)?'selected="selected "':'')." value=\"".$continent."\">".$continent."</option>"; //Timezone 2982 } 2983 2984 $selectcontinent = $continent; 2985 } 2986 } 2987 $structure .= '</optgroup>'; 2988 return $structure; 2989 } 2990 2991 2992 ?> 2993 No newline at end of file