]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/options-general.php
cd4b8cdb3ad5731fb0900a0124f9d4f5804b3ee5
[autoinstalls/wordpress.git] / wp-admin / options-general.php
1 <?php
2 /**
3  * General settings administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_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  */
23 function 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 }
48 add_filter('admin_head', 'add_js');
49
50 include('./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
99 if ( !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);
108 foreach ( $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
136 else: // looks like we can do nice timezone selection!
137 $current_offset = get_option('gmt_offset');
138 $tzstring = get_option('timezone_string');
139 if (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 (get_option('timezone_string')) : ?>
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') && $tzstring) {
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                         $tz = new DateTimeZone($tzstring);
183                         $d = new DateTime( "@{$tr['ts']}" );
184                         $d->setTimezone($tz);
185                         printf( $message, date_i18n(get_option('date_format').' '.get_option('time_format'), $d->format('U') ) );
186                 } else {
187                         _e('This timezone does not observe daylight savings time.');
188                 }
189         }
190         ?>
191         </span>
192 <?php endif; ?>
193 </td>
194
195 <?php endif; ?>
196 </tr>
197 <tr>
198 <th scope="row"><?php _e('Date Format') ?></th>
199 <td>
200         <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
201 <?php
202
203         $date_formats = apply_filters( 'date_formats', array(
204                 __('F j, Y'),
205                 'Y/m/d',
206                 'm/d/Y',
207                 'd/m/Y',
208         ) );
209
210         $custom = TRUE;
211
212         foreach ( $date_formats as $format ) {
213                 echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'";
214                 if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
215                         echo " checked='checked'";
216                         $custom = FALSE;
217                 }
218                 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
219         }
220
221         echo '  <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
222         checked( $custom );
223         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";
224
225         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";
226 ?>
227         </fieldset>
228 </td>
229 </tr>
230 <tr>
231 <th scope="row"><?php _e('Time Format') ?></th>
232 <td>
233         <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
234 <?php
235
236         $time_formats = apply_filters( 'time_formats', array(
237                 __('g:i a'),
238                 'g:i A',
239                 'H:i',
240         ) );
241
242         $custom = TRUE;
243
244         foreach ( $time_formats as $format ) {
245                 echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'";
246                 if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
247                         echo " checked='checked'";
248                         $custom = FALSE;
249                 }
250                 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
251         }
252
253         echo '  <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
254         checked( $custom );
255         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";
256 ?>
257         </fieldset>
258 </td>
259 </tr>
260 <tr>
261 <th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th>
262 <td><select name="start_of_week" id="start_of_week">
263 <?php
264 for ($day_index = 0; $day_index <= 6; $day_index++) :
265         $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';
266         echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
267 endfor;
268 ?>
269 </select></td>
270 </tr>
271 <?php do_settings_fields('general', 'default'); ?>
272 </table>
273
274 <?php do_settings_sections('general'); ?>
275
276 <p class="submit">
277 <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
278 </p>
279 </form>
280
281 </div>
282
283 <?php include('./admin-footer.php') ?>