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