| 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) . "\">" . 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 | <?php |
|---|
| 148 | function locateIp($ip){ |
|---|
| 149 | $d = file_get_contents("http://www.ipinfodb.com/ip_query.php?ip=$ip&output=xml"); |
|---|
| 150 | |
|---|
| 151 | //Use backup server if cannot make a connection |
|---|
| 152 | if (!$d){ |
|---|
| 153 | $backup = file_get_contents("http://backup.ipinfodb.com/ip_query.php?ip=$ip&output=xml"); |
|---|
| 154 | $answer = new SimpleXMLElement($backup); |
|---|
| 155 | if (!$backup) return false; // Failed to open connection |
|---|
| 156 | }else{ |
|---|
| 157 | $answer = new SimpleXMLElement($d); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | $country_code = $answer->CountryCode; |
|---|
| 161 | $country_name = $answer->CountryName; |
|---|
| 162 | $region_name = $answer->RegionName; |
|---|
| 163 | $city = $answer->City; |
|---|
| 164 | $zippostalcode = $answer->ZipPostalCode; |
|---|
| 165 | $latitude = $answer->Latitude; |
|---|
| 166 | $longitude = $answer->Longitude; |
|---|
| 167 | $gmtoffset = $answer->Gmtoffset; |
|---|
| 168 | $dstoffset = $answer->Dstoffset; |
|---|
| 169 | |
|---|
| 170 | //Return the data as an array |
|---|
| 171 | return array('ip' => $ip, 'country_code' => $country_code, 'country_name' => $country_name, 'region_name' => $region_name, 'city' => $city, 'zippostalcode' => $zippostalcode, 'latitude' => $latitude, 'longitude' => $longitude, 'gmtoffset' => $gmtoffset, 'dstoffset' => $dstoffset); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | //Usage example |
|---|
| 175 | $ip = $_SERVER['REMOTE_ADDR']; |
|---|
| 176 | $ip_data = locateIp($ip); |
|---|
| 177 | |
|---|
| 178 | //echo "Country name : " . $ip_data['city'] . "\n"; |
|---|
| 179 | //echo "GmtOffset : " . $ip_data['gmtoffset'] . "\n"; |
|---|
| 180 | //<select id="timezone_string" name="".$ip_data['country_name'].> |
|---|
| 181 | |
|---|
| 182 | echo '<select id="timezone_string" name="timezone_string">'; |
|---|
| 183 | |
|---|
| 184 | echo '<option selected="selected" value="1">'.$ip_data['city'].' (GMT: '.$ip_data['gmtoffset'].')</option>'; |
|---|
| 185 | echo wp_timezone_choice($tzstring); ?> |
|---|
| 186 | |
|---|
| 187 | </select> |
|---|
| 188 | |
|---|
| 189 | <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> |
|---|
| 190 | <?php if (get_option('timezone_string')) : ?> |
|---|
| 191 | <span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span> |
|---|
| 192 | <?php endif; ?> |
|---|
| 193 | <br /> |
|---|
| 194 | <span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span> |
|---|
| 195 | <br /> |
|---|
| 196 | <span> |
|---|
| 197 | <?php if ($tzstring) : ?> |
|---|
| 198 | <?php |
|---|
| 199 | $now = localtime(time(),true); |
|---|
| 200 | if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.'); |
|---|
| 201 | else _e('This timezone is currently in standard time.'); |
|---|
| 202 | ?> |
|---|
| 203 | <br /> |
|---|
| 204 | <?php |
|---|
| 205 | if (function_exists('timezone_transitions_get')) { |
|---|
| 206 | $dateTimeZoneSelected = new DateTimeZone($tzstring); |
|---|
| 207 | foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) { |
|---|
| 208 | if ($tr['ts'] > time()) { |
|---|
| 209 | $found = true; |
|---|
| 210 | break; |
|---|
| 211 | } |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | if ( isset($found) && $found === true ) { |
|---|
| 215 | echo ' '; |
|---|
| 216 | $message = $tr['isdst'] ? |
|---|
| 217 | __('Daylight savings time begins on: <code>%s</code>.') : |
|---|
| 218 | __('Standard time begins on: <code>%s</code>.'); |
|---|
| 219 | printf( $message, date_i18n(get_option('date_format').' '.get_option('time_format'), $tr['ts'] ) ); |
|---|
| 220 | } else { |
|---|
| 221 | _e('This timezone does not observe daylight savings time.'); |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | ?> |
|---|
| 225 | </span> |
|---|
| 226 | <?php endif; ?> |
|---|
| 227 | </td> |
|---|
| 228 | |
|---|
| 229 | <?php endif; ?> |
|---|
| 230 | </tr> |
|---|
| 231 | <tr> |
|---|
| 232 | <th scope="row"><?php _e('Date Format') ?></th> |
|---|
| 233 | <td> |
|---|
| 234 | <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend> |
|---|
| 235 | <?php |
|---|
| 236 | |
|---|
| 237 | $date_formats = apply_filters( 'date_formats', array( |
|---|
| 238 | __('F j, Y'), |
|---|
| 239 | 'Y/m/d', |
|---|
| 240 | 'm/d/Y', |
|---|
| 241 | 'd/m/Y', |
|---|
| 242 | ) ); |
|---|
| 243 | |
|---|
| 244 | $custom = TRUE; |
|---|
| 245 | |
|---|
| 246 | foreach ( $date_formats as $format ) { |
|---|
| 247 | echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'"; |
|---|
| 248 | if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "===" |
|---|
| 249 | echo " checked='checked'"; |
|---|
| 250 | $custom = FALSE; |
|---|
| 251 | } |
|---|
| 252 | echo ' /> ' . date_i18n( $format ) . "</label><br />\n"; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | echo ' <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; |
|---|
| 256 | checked( $custom ); |
|---|
| 257 | 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"; |
|---|
| 258 | |
|---|
| 259 | echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click “Save Changes” to update sample output.') . "</p>\n"; |
|---|
| 260 | ?> |
|---|
| 261 | </fieldset> |
|---|
| 262 | </td> |
|---|
| 263 | </tr> |
|---|
| 264 | <tr> |
|---|
| 265 | <th scope="row"><?php _e('Time Format') ?></th> |
|---|
| 266 | <td> |
|---|
| 267 | <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend> |
|---|
| 268 | <?php |
|---|
| 269 | |
|---|
| 270 | $time_formats = apply_filters( 'time_formats', array( |
|---|
| 271 | __('g:i a'), |
|---|
| 272 | 'g:i A', |
|---|
| 273 | 'H:i', |
|---|
| 274 | ) ); |
|---|
| 275 | |
|---|
| 276 | $custom = TRUE; |
|---|
| 277 | |
|---|
| 278 | foreach ( $time_formats as $format ) { |
|---|
| 279 | echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'"; |
|---|
| 280 | if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "===" |
|---|
| 281 | echo " checked='checked'"; |
|---|
| 282 | $custom = FALSE; |
|---|
| 283 | } |
|---|
| 284 | echo ' /> ' . date_i18n( $format ) . "</label><br />\n"; |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | echo ' <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; |
|---|
| 288 | checked( $custom ); |
|---|
| 289 | 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"; |
|---|
| 290 | ?> |
|---|
| 291 | </fieldset> |
|---|
| 292 | </td> |
|---|
| 293 | </tr> |
|---|
| 294 | <tr> |
|---|
| 295 | <th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th> |
|---|
| 296 | <td><select name="start_of_week" id="start_of_week"> |
|---|
| 297 | <?php |
|---|
| 298 | for ($day_index = 0; $day_index <= 6; $day_index++) : |
|---|
| 299 | $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : ''; |
|---|
| 300 | echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; |
|---|
| 301 | endfor; |
|---|
| 302 | ?> |
|---|
| 303 | </select></td> |
|---|
| 304 | </tr> |
|---|
| 305 | <?php do_settings_fields('general', 'default'); ?> |
|---|
| 306 | </table> |
|---|
| 307 | |
|---|
| 308 | <?php do_settings_sections('general'); ?> |
|---|
| 309 | |
|---|
| 310 | <p class="submit"> |
|---|
| 311 | <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> |
|---|
| 312 | </p> |
|---|
| 313 | </form> |
|---|
| 314 | |
|---|
| 315 | </div> |
|---|
| 316 | |
|---|
| 317 | <?php include('./admin-footer.php') ?> |
|---|