source: trunk/www.guidonia.net/wp/wp-admin/options-general.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 10.4 KB
Line 
1<?php
2/**
3 * General settings administration panel.
4 *
5 * @package WordPress
6 * @subpackage Administration
7 */
8
9/** WordPress Administration Bootstrap */
10require_once('./admin.php');
11
12$title = __('General Settings');
13$parent_file = 'options-general.php';
14/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
15$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
16
17/**
18 * Display JavaScript on the page.
19 *
20 * @package WordPress
21 * @subpackage General_Settings_Panel
22 */
23function add_js() {
24?>
25<script type="text/javascript">
26//<![CDATA[
27 jQuery(document).ready(function($){
28 $("input[name='date_format']").click(function(){
29 if ( "date_format_custom_radio" != $(this).attr("id") )
30 $("input[name='date_format_custom']").val( $(this).val() );
31 });
32 $("input[name='date_format_custom']").focus(function(){
33 $("#date_format_custom_radio").attr("checked", "checked");
34 });
35
36 $("input[name='time_format']").click(function(){
37 if ( "time_format_custom_radio" != $(this).attr("id") )
38 $("input[name='time_format_custom']").val( $(this).val() );
39 });
40 $("input[name='time_format_custom']").focus(function(){
41 $("#time_format_custom_radio").attr("checked", "checked");
42 });
43 });
44//]]>
45</script>
46<?php
47}
48add_filter('admin_head', 'add_js');
49
50include('./admin-header.php');
51?>
52
53<div class="wrap">
54<?php screen_icon(); ?>
55<h2><?php echo esc_html( $title ); ?></h2>
56
57<form method="post" action="options.php">
58<?php settings_fields('general'); ?>
59
60<table class="form-table">
61<tr valign="top">
62<th scope="row"><label for="blogname"><?php _e('Blog Title') ?></label></th>
63<td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" class="regular-text" /></td>
64</tr>
65<tr valign="top">
66<th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th>
67<td><input name="blogdescription" type="text" id="blogdescription" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
68<span class="description"><?php _e('In a few words, explain what this blog is about.') ?></span></td>
69</tr>
70<tr valign="top">
71<th scope="row"><label for="siteurl"><?php _e('WordPress address (URL)') ?></label></th>
72<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
73</tr>
74<tr valign="top">
75<th scope="row"><label for="home"><?php _e('Blog address (URL)') ?></label></th>
76<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" class="regular-text code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> />
77<span class="description"><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></span></td>
78</tr>
79<tr valign="top">
80<th scope="row"><label for="admin_email"><?php _e('E-mail address') ?> </label></th>
81<td><input name="admin_email" type="text" id="admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text" />
82<span class="description"><?php _e('This address is used for admin purposes, like new user notification.') ?></span></td>
83</tr>
84<tr valign="top">
85<th scope="row"><?php _e('Membership') ?></th>
86<td> <fieldset><legend class="screen-reader-text"><span><?php _e('Membership') ?></span></legend><label for="users_can_register">
87<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
88<?php _e('Anyone can register') ?></label>
89</fieldset></td>
90</tr>
91<tr valign="top">
92<th scope="row"><label for="default_role"><?php _e('New User Default Role') ?></label></th>
93<td>
94<select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select>
95</td>
96</tr>
97<tr>
98<?php
99if ( !wp_timezone_supported() ) : // no magic timezone support here
100?>
101<th scope="row"><label for="gmt_offset"><?php _e('Timezone') ?> </label></th>
102<td>
103<select name="gmt_offset" id="gmt_offset">
104<?php
105$current_offset = get_option('gmt_offset');
106$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,
107 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);
108foreach ( $offset_range as $offset ) {
109 if ( 0 < $offset )
110 $offset_name = '+' . $offset;
111 elseif ( 0 == $offset )
112 $offset_name = '';
113 else
114 $offset_name = (string) $offset;
115
116 $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
117
118 $selected = '';
119 if ( $current_offset == $offset ) {
120 $selected = " selected='selected'";
121 $current_offset_name = $offset_name;
122 }
123 echo "<option value=\"" . esc_attr($offset) . "\"$selected>" . sprintf(__('UTC %s'), $offset_name) . '</option>';
124}
125?>
126</select>
127<?php _e('hours'); ?>
128<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n( $time_format, false, 'gmt')); ?></span>
129<?php if ($current_offset) : ?>
130 <span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n($time_format)); ?></span>
131<?php endif; ?>
132<br />
133<span class="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>
134</td>
135<?php
136else: // looks like we can do nice timezone selection!
137$current_offset = get_option('gmt_offset');
138$tzstring = get_option('timezone_string');
139if (empty($tzstring)) { // set the Etc zone if no timezone string exists
140 if ($current_offset < 0) $offnum = - ceil($current_offset);
141 else $offnum = - floor($current_offset);
142 $tzstring = 'Etc/GMT' . (($offnum >= 0) ? '+' : '') . $offnum;
143}
144?>
145<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
146<td>
147
148<select id="timezone_string" name="timezone_string">
149<?php echo wp_timezone_choice($tzstring); ?>
150</select>
151
152 <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt')); ?></span>
153<?php if (get_option('timezone_string')) : ?>
154 <span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span>
155<?php endif; ?>
156<br />
157<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
158<br />
159<span>
160<?php if ($tzstring) : ?>
161 <?php
162 $now = localtime(time(),true);
163 if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
164 else _e('This timezone is currently in standard time.');
165 ?>
166 <br />
167 <?php
168 if (function_exists('timezone_transitions_get')) {
169 $dateTimeZoneSelected = new DateTimeZone($tzstring);
170 foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) {
171 if ($tr['ts'] > time()) {
172 $found = true;
173 break;
174 }
175 }
176
177 if ( isset($found) && $found === true ) {
178 echo ' ';
179 $message = $tr['isdst'] ?
180 __('Daylight savings time begins on: <code>%s</code>.') :
181 __('Standard time begins on: <code>%s</code>.');
182 printf( $message, date_i18n(get_option('date_format').' '.get_option('time_format'), $tr['ts'] ) );
183 } else {
184 _e('This timezone does not observe daylight savings time.');
185 }
186 }
187 ?>
188 </span>
189<?php endif; ?>
190</td>
191
192<?php endif; ?>
193</tr>
194<tr>
195<th scope="row"><?php _e('Date Format') ?></th>
196<td>
197 <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
198<?php
199
200 $date_formats = apply_filters( 'date_formats', array(
201 __('F j, Y'),
202 'Y/m/d',
203 'm/d/Y',
204 'd/m/Y',
205 ) );
206
207 $custom = TRUE;
208
209 foreach ( $date_formats as $format ) {
210 echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'";
211 if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
212 echo " checked='checked'";
213 $custom = FALSE;
214 }
215 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
216 }
217
218 echo ' <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
219 checked( $custom );
220 echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( get_option('date_format') ) . '" class="small-text" /> ' . date_i18n( get_option('date_format') ) . "\n";
221
222 echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click &#8220;Save Changes&#8221; to update sample output.') . "</p>\n";
223?>
224 </fieldset>
225</td>
226</tr>
227<tr>
228<th scope="row"><?php _e('Time Format') ?></th>
229<td>
230 <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
231<?php
232
233 $time_formats = apply_filters( 'time_formats', array(
234 __('g:i a'),
235 'g:i A',
236 'H:i',
237 ) );
238
239 $custom = TRUE;
240
241 foreach ( $time_formats as $format ) {
242 echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'";
243 if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
244 echo " checked='checked'";
245 $custom = FALSE;
246 }
247 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
248 }
249
250 echo ' <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
251 checked( $custom );
252 echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( get_option('time_format') ) . '" class="small-text" /> ' . date_i18n( get_option('time_format') ) . "\n";
253?>
254 </fieldset>
255</td>
256</tr>
257<tr>
258<th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th>
259<td><select name="start_of_week" id="start_of_week">
260<?php
261for ($day_index = 0; $day_index <= 6; $day_index++) :
262 $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';
263 echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
264endfor;
265?>
266</select></td>
267</tr>
268<?php do_settings_fields('general', 'default'); ?>
269</table>
270
271<?php do_settings_sections('general'); ?>
272
273<p class="submit">
274<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
275</p>
276</form>
277
278</div>
279
280<?php include('./admin-footer.php') ?>
Note: See TracBrowser for help on using the repository browser.