PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/options-general.php

http://github.com/wordpress/wordpress
PHP | 408 lines | 319 code | 51 blank | 38 comment | 39 complexity | ce87292d8cb94fd372dd7fa2ac8952c2 MD5 | raw file
Possible License(s): 0BSD
  1. <?php
  2. /**
  3. * General settings administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once __DIR__ . '/admin.php';
  10. /** WordPress Translation Installation API */
  11. require_once ABSPATH . 'wp-admin/includes/translation-install.php';
  12. if ( ! current_user_can( 'manage_options' ) ) {
  13. wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
  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 https://www.php.net/date */
  18. $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
  19. add_action( 'admin_head', 'options_general_add_js' );
  20. $options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' .
  21. '<p>' . __( 'Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.' ) . '</p>';
  22. if ( ! is_multisite() ) {
  23. $options_help .= '<p>' . __( 'The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.' ) . '</p>' .
  24. '<p>' . __( 'If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.' ) . '</p>';
  25. }
  26. $options_help .= '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' .
  27. '<p>' . __( 'UTC means Coordinated Universal Time.' ) . '</p>' .
  28. '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>';
  29. get_current_screen()->add_help_tab(
  30. array(
  31. 'id' => 'overview',
  32. 'title' => __( 'Overview' ),
  33. 'content' => $options_help,
  34. )
  35. );
  36. get_current_screen()->set_help_sidebar(
  37. '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  38. '<p>' . __( '<a href="https://wordpress.org/support/article/settings-general-screen/">Documentation on General Settings</a>' ) . '</p>' .
  39. '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  40. );
  41. require_once ABSPATH . 'wp-admin/admin-header.php';
  42. ?>
  43. <div class="wrap">
  44. <h1><?php echo esc_html( $title ); ?></h1>
  45. <form method="post" action="options.php" novalidate="novalidate">
  46. <?php settings_fields( 'general' ); ?>
  47. <table class="form-table" role="presentation">
  48. <tr>
  49. <th scope="row"><label for="blogname"><?php _e( 'Site Title' ); ?></label></th>
  50. <td><input name="blogname" type="text" id="blogname" value="<?php form_option( 'blogname' ); ?>" class="regular-text" /></td>
  51. </tr>
  52. <tr>
  53. <th scope="row"><label for="blogdescription"><?php _e( 'Tagline' ); ?></label></th>
  54. <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option( 'blogdescription' ); ?>" class="regular-text" />
  55. <p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ); ?></p></td>
  56. </tr>
  57. <?php
  58. if ( ! is_multisite() ) {
  59. $wp_site_url_class = '';
  60. $wp_home_class = '';
  61. if ( defined( 'WP_SITEURL' ) ) {
  62. $wp_site_url_class = ' disabled';
  63. }
  64. if ( defined( 'WP_HOME' ) ) {
  65. $wp_home_class = ' disabled';
  66. }
  67. ?>
  68. <tr>
  69. <th scope="row"><label for="siteurl"><?php _e( 'WordPress Address (URL)' ); ?></label></th>
  70. <td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php echo $wp_site_url_class; ?>" /></td>
  71. </tr>
  72. <tr>
  73. <th scope="row"><label for="home"><?php _e( 'Site Address (URL)' ); ?></label></th>
  74. <td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php echo $wp_home_class; ?>" />
  75. <?php if ( ! defined( 'WP_HOME' ) ) : ?>
  76. <p class="description" id="home-description">
  77. <?php
  78. printf(
  79. /* translators: %s: Documentation URL. */
  80. __( 'Enter the address here if you <a href="%s">want your site home page to be different from your WordPress installation directory</a>.' ),
  81. __( 'https://wordpress.org/support/article/giving-wordpress-its-own-directory/' )
  82. );
  83. ?>
  84. </p>
  85. <?php endif; ?>
  86. </td>
  87. </tr>
  88. <?php } ?>
  89. <tr>
  90. <th scope="row"><label for="new_admin_email"><?php _e( 'Administration Email Address' ); ?></label></th>
  91. <td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
  92. <p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this, we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
  93. <?php
  94. $new_admin_email = get_option( 'new_admin_email' );
  95. if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) :
  96. ?>
  97. <div class="updated inline">
  98. <p>
  99. <?php
  100. printf(
  101. /* translators: %s: New admin email. */
  102. __( 'There is a pending change of the admin email to %s.' ),
  103. '<code>' . esc_html( $new_admin_email ) . '</code>'
  104. );
  105. printf(
  106. ' <a href="%1$s">%2$s</a>',
  107. esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
  108. __( 'Cancel' )
  109. );
  110. ?>
  111. </p>
  112. </div>
  113. <?php endif; ?>
  114. </td>
  115. </tr>
  116. <?php if ( ! is_multisite() ) { ?>
  117. <tr>
  118. <th scope="row"><?php _e( 'Membership' ); ?></th>
  119. <td> <fieldset><legend class="screen-reader-text"><span><?php _e( 'Membership' ); ?></span></legend><label for="users_can_register">
  120. <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> />
  121. <?php _e( 'Anyone can register' ); ?></label>
  122. </fieldset></td>
  123. </tr>
  124. <tr>
  125. <th scope="row"><label for="default_role"><?php _e( 'New User Default Role' ); ?></label></th>
  126. <td>
  127. <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select>
  128. </td>
  129. </tr>
  130. <?php
  131. }
  132. $languages = get_available_languages();
  133. $translations = wp_get_available_translations();
  134. if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages, true ) ) {
  135. $languages[] = WPLANG;
  136. }
  137. if ( ! empty( $languages ) || ! empty( $translations ) ) {
  138. ?>
  139. <tr>
  140. <th scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th>
  141. <td>
  142. <?php
  143. $locale = get_locale();
  144. if ( ! in_array( $locale, $languages, true ) ) {
  145. $locale = '';
  146. }
  147. wp_dropdown_languages(
  148. array(
  149. 'name' => 'WPLANG',
  150. 'id' => 'WPLANG',
  151. 'selected' => $locale,
  152. 'languages' => $languages,
  153. 'translations' => $translations,
  154. 'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
  155. )
  156. );
  157. // Add note about deprecated WPLANG constant.
  158. if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && WPLANG !== $locale ) {
  159. _deprecated_argument(
  160. 'define()',
  161. '4.0.0',
  162. /* translators: 1: WPLANG, 2: wp-config.php */
  163. sprintf( __( 'The %1$s constant in your %2$s file is no longer needed.' ), 'WPLANG', 'wp-config.php' )
  164. );
  165. }
  166. ?>
  167. </td>
  168. </tr>
  169. <?php
  170. }
  171. ?>
  172. <tr>
  173. <?php
  174. $current_offset = get_option( 'gmt_offset' );
  175. $tzstring = get_option( 'timezone_string' );
  176. $check_zone_info = true;
  177. // Remove old Etc mappings. Fallback to gmt_offset.
  178. if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
  179. $tzstring = '';
  180. }
  181. if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
  182. $check_zone_info = false;
  183. if ( 0 == $current_offset ) {
  184. $tzstring = 'UTC+0';
  185. } elseif ( $current_offset < 0 ) {
  186. $tzstring = 'UTC' . $current_offset;
  187. } else {
  188. $tzstring = 'UTC+' . $current_offset;
  189. }
  190. }
  191. ?>
  192. <th scope="row"><label for="timezone_string"><?php _e( 'Timezone' ); ?></label></th>
  193. <td>
  194. <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
  195. <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?>
  196. </select>
  197. <p class="description" id="timezone-description">
  198. <?php
  199. printf(
  200. /* translators: %s: UTC abbreviation */
  201. __( 'Choose either a city in the same timezone as you or a %s (Coordinated Universal Time) time offset.' ),
  202. '<abbr>UTC</abbr>'
  203. );
  204. ?>
  205. </p>
  206. <p class="timezone-info">
  207. <span id="utc-time">
  208. <?php
  209. printf(
  210. /* translators: %s: UTC time. */
  211. __( 'Universal time is %s.' ),
  212. '<code>' . date_i18n( $timezone_format, false, true ) . '</code>'
  213. );
  214. ?>
  215. </span>
  216. <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
  217. <span id="local-time">
  218. <?php
  219. printf(
  220. /* translators: %s: Local time. */
  221. __( 'Local time is %s.' ),
  222. '<code>' . date_i18n( $timezone_format ) . '</code>'
  223. );
  224. ?>
  225. </span>
  226. <?php endif; ?>
  227. </p>
  228. <?php if ( $check_zone_info && $tzstring ) : ?>
  229. <p class="timezone-info">
  230. <span>
  231. <?php
  232. $now = new DateTime( 'now', new DateTimeZone( $tzstring ) );
  233. $dst = (bool) $now->format( 'I' );
  234. if ( $dst ) {
  235. _e( 'This timezone is currently in daylight saving time.' );
  236. } else {
  237. _e( 'This timezone is currently in standard time.' );
  238. }
  239. ?>
  240. <br />
  241. <?php
  242. if ( in_array( $tzstring, timezone_identifiers_list(), true ) ) {
  243. $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
  244. // 0 index is the state at current time, 1 index is the next transition, if any.
  245. if ( ! empty( $transitions[1] ) ) {
  246. echo ' ';
  247. $message = $transitions[1]['isdst'] ?
  248. /* translators: %s: Date and time. */
  249. __( 'Daylight saving time begins on: %s.' ) :
  250. /* translators: %s: Date and time. */
  251. __( 'Standard time begins on: %s.' );
  252. printf(
  253. $message,
  254. '<code>' . wp_date( __( 'F j, Y' ) . ' ' . __( 'g:i a' ), $transitions[1]['ts'] ) . '</code>'
  255. );
  256. } else {
  257. _e( 'This timezone does not observe daylight saving time.' );
  258. }
  259. }
  260. ?>
  261. </span>
  262. </p>
  263. <?php endif; ?>
  264. </td>
  265. </tr>
  266. <tr>
  267. <th scope="row"><?php _e( 'Date Format' ); ?></th>
  268. <td>
  269. <fieldset><legend class="screen-reader-text"><span><?php _e( 'Date Format' ); ?></span></legend>
  270. <?php
  271. /**
  272. * Filters the default date formats.
  273. *
  274. * @since 2.7.0
  275. * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
  276. *
  277. * @param string[] $default_date_formats Array of default date formats.
  278. */
  279. $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
  280. $custom = true;
  281. foreach ( $date_formats as $format ) {
  282. echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
  283. if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
  284. echo " checked='checked'";
  285. $custom = false;
  286. }
  287. echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
  288. }
  289. echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
  290. checked( $custom );
  291. echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom date format in the following field' ) . '</span></span></label>' .
  292. '<label for="date_format_custom" class="screen-reader-text">' . __( 'Custom date format:' ) . '</label>' .
  293. '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" />' .
  294. '<br />' .
  295. '<p><strong>' . __( 'Preview:' ) . '</strong> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' .
  296. "<span class='spinner'></span>\n" . '</p>';
  297. ?>
  298. </fieldset>
  299. </td>
  300. </tr>
  301. <tr>
  302. <th scope="row"><?php _e( 'Time Format' ); ?></th>
  303. <td>
  304. <fieldset><legend class="screen-reader-text"><span><?php _e( 'Time Format' ); ?></span></legend>
  305. <?php
  306. /**
  307. * Filters the default time formats.
  308. *
  309. * @since 2.7.0
  310. *
  311. * @param string[] $default_time_formats Array of default time formats.
  312. */
  313. $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) );
  314. $custom = true;
  315. foreach ( $time_formats as $format ) {
  316. echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
  317. if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
  318. echo " checked='checked'";
  319. $custom = false;
  320. }
  321. echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
  322. }
  323. echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
  324. checked( $custom );
  325. echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom time format in the following field' ) . '</span></span></label>' .
  326. '<label for="time_format_custom" class="screen-reader-text">' . __( 'Custom time format:' ) . '</label>' .
  327. '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" />' .
  328. '<br />' .
  329. '<p><strong>' . __( 'Preview:' ) . '</strong> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' .
  330. "<span class='spinner'></span>\n" . '</p>';
  331. echo "\t<p class='date-time-doc'>" . __( '<a href="https://wordpress.org/support/article/formatting-date-and-time/">Documentation on date and time formatting</a>.' ) . "</p>\n";
  332. ?>
  333. </fieldset>
  334. </td>
  335. </tr>
  336. <tr>
  337. <th scope="row"><label for="start_of_week"><?php _e( 'Week Starts On' ); ?></label></th>
  338. <td><select name="start_of_week" id="start_of_week">
  339. <?php
  340. /**
  341. * @global WP_Locale $wp_locale WordPress date and time locale object.
  342. */
  343. global $wp_locale;
  344. for ( $day_index = 0; $day_index <= 6; $day_index++ ) :
  345. $selected = ( get_option( 'start_of_week' ) == $day_index ) ? 'selected="selected"' : '';
  346. echo "\n\t<option value='" . esc_attr( $day_index ) . "' $selected>" . $wp_locale->get_weekday( $day_index ) . '</option>';
  347. endfor;
  348. ?>
  349. </select></td>
  350. </tr>
  351. <?php do_settings_fields( 'general', 'default' ); ?>
  352. </table>
  353. <?php do_settings_sections( 'general' ); ?>
  354. <?php submit_button(); ?>
  355. </form>
  356. </div>
  357. <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>