PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/options-general.php

https://bitbucket.org/acipriani/madeinapulia.com
PHP | 385 lines | 303 code | 43 blank | 39 comment | 49 complexity | d05abbeef1686261b73111eaf7b6926e MD5 | raw file
Possible License(s): GPL-3.0, MIT, BSD-3-Clause, LGPL-2.1, GPL-2.0, Apache-2.0
  1. <?php
  2. /**
  3. * General settings administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( dirname( __FILE__ ) . '/admin.php' );
  10. /** WordPress Translation Install API */
  11. require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
  12. if ( ! current_user_can( 'manage_options' ) )
  13. wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
  14. $title = __('General Settings');
  15. $parent_file = 'options-general.php';
  16. /* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
  17. $timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
  18. /**
  19. * Display JavaScript on the page.
  20. *
  21. * @since 3.5.0
  22. */
  23. function options_general_add_js() {
  24. ?>
  25. <script type="text/javascript">
  26. //<![CDATA[
  27. jQuery(document).ready(function($){
  28. var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
  29. homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
  30. $( '#blogname' ).on( 'input', function() {
  31. var title = $.trim( $( this ).val() ) || homeURL;
  32. // Truncate to 40 characters.
  33. if ( 40 < title.length ) {
  34. title = title.substring( 0, 40 ) + '\u2026';
  35. }
  36. $siteName.text( title );
  37. });
  38. $("input[name='date_format']").click(function(){
  39. if ( "date_format_custom_radio" != $(this).attr("id") )
  40. $("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
  41. });
  42. $("input[name='date_format_custom']").focus(function(){
  43. $( '#date_format_custom_radio' ).prop( 'checked', true );
  44. });
  45. $("input[name='time_format']").click(function(){
  46. if ( "time_format_custom_radio" != $(this).attr("id") )
  47. $("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
  48. });
  49. $("input[name='time_format_custom']").focus(function(){
  50. $( '#time_format_custom_radio' ).prop( 'checked', true );
  51. });
  52. $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
  53. var format = $(this);
  54. format.siblings('.spinner').css('display', 'inline-block'); // show(); can't be used here
  55. $.post(ajaxurl, {
  56. action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
  57. date : format.val()
  58. }, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
  59. });
  60. var languageSelect = $( '#WPLANG' );
  61. $( 'form' ).submit( function() {
  62. // Don't show a spinner for English and installed languages,
  63. // as there is nothing to download.
  64. if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
  65. $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
  66. }
  67. });
  68. });
  69. //]]>
  70. </script>
  71. <?php
  72. }
  73. add_action('admin_head', 'options_general_add_js');
  74. $options_help = '<p>' . __('The fields on this screen determine some of the basics of your site setup.') . '</p>' .
  75. '<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>';
  76. if ( ! is_multisite() ) {
  77. $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>' .
  78. '<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>';
  79. }
  80. $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>' .
  81. '<p>' . __( 'UTC means Coordinated Universal Time.' ) . '</p>' .
  82. '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>';
  83. get_current_screen()->add_help_tab( array(
  84. 'id' => 'overview',
  85. 'title' => __('Overview'),
  86. 'content' => $options_help,
  87. ) );
  88. get_current_screen()->set_help_sidebar(
  89. '<p><strong>' . __('For more information:') . '</strong></p>' .
  90. '<p>' . __('<a href="http://codex.wordpress.org/Settings_General_Screen" target="_blank">Documentation on General Settings</a>') . '</p>' .
  91. '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  92. );
  93. include( ABSPATH . 'wp-admin/admin-header.php' );
  94. ?>
  95. <div class="wrap">
  96. <h2><?php echo esc_html( $title ); ?></h2>
  97. <form method="post" action="options.php" novalidate="novalidate">
  98. <?php settings_fields('general'); ?>
  99. <table class="form-table">
  100. <tr>
  101. <th scope="row"><label for="blogname"><?php _e('Site Title') ?></label></th>
  102. <td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" class="regular-text" /></td>
  103. </tr>
  104. <tr>
  105. <th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th>
  106. <td><input name="blogdescription" type="text" id="blogdescription" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
  107. <p class="description"><?php _e('In a few words, explain what this site is about.') ?></p></td>
  108. </tr>
  109. <?php if ( !is_multisite() ) { ?>
  110. <tr>
  111. <th scope="row"><label for="siteurl"><?php _e('WordPress Address (URL)') ?></label></th>
  112. <td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" /></td>
  113. </tr>
  114. <tr>
  115. <th scope="row"><label for="home"><?php _e('Site Address (URL)') ?></label></th>
  116. <td><input name="home" type="url" id="home" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" />
  117. <p class="description"><?php _e('Enter the address here if you want your site homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></p></td>
  118. </tr>
  119. <tr>
  120. <th scope="row"><label for="admin_email"><?php _e('E-mail Address') ?> </label></th>
  121. <td><input name="admin_email" type="email" id="admin_email" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
  122. <p class="description"><?php _e('This address is used for admin purposes, like new user notification.') ?></p></td>
  123. </tr>
  124. <tr>
  125. <th scope="row"><?php _e('Membership') ?></th>
  126. <td> <fieldset><legend class="screen-reader-text"><span><?php _e('Membership') ?></span></legend><label for="users_can_register">
  127. <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
  128. <?php _e('Anyone can register') ?></label>
  129. </fieldset></td>
  130. </tr>
  131. <tr>
  132. <th scope="row"><label for="default_role"><?php _e('New User Default Role') ?></label></th>
  133. <td>
  134. <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select>
  135. </td>
  136. </tr>
  137. <?php } else { ?>
  138. <tr>
  139. <th scope="row"><label for="new_admin_email"><?php _e('E-mail Address') ?> </label></th>
  140. <td><input name="new_admin_email" type="email" id="new_admin_email" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
  141. <p class="description"><?php _e('This address is used for admin purposes. If you change this we will send you an e-mail at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></p>
  142. <?php
  143. $new_admin_email = get_option( 'new_admin_email' );
  144. if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?>
  145. <div class="updated inline">
  146. <p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), esc_html( $new_admin_email ), esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
  147. </div>
  148. <?php endif; ?>
  149. </td>
  150. </tr>
  151. <?php } ?>
  152. <tr>
  153. <?php
  154. $current_offset = get_option('gmt_offset');
  155. $tzstring = get_option('timezone_string');
  156. $check_zone_info = true;
  157. // Remove old Etc mappings. Fallback to gmt_offset.
  158. if ( false !== strpos($tzstring,'Etc/GMT') )
  159. $tzstring = '';
  160. if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
  161. $check_zone_info = false;
  162. if ( 0 == $current_offset )
  163. $tzstring = 'UTC+0';
  164. elseif ($current_offset < 0)
  165. $tzstring = 'UTC' . $current_offset;
  166. else
  167. $tzstring = 'UTC+' . $current_offset;
  168. }
  169. ?>
  170. <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
  171. <td>
  172. <select id="timezone_string" name="timezone_string">
  173. <?php echo wp_timezone_choice($tzstring); ?>
  174. </select>
  175. <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>
  176. <?php if ( get_option('timezone_string') || !empty($current_offset) ) : ?>
  177. <span id="local-time"><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span>
  178. <?php endif; ?>
  179. <p class="description"><?php _e('Choose a city in the same timezone as you.'); ?></p>
  180. <?php if ($check_zone_info && $tzstring) : ?>
  181. <br />
  182. <span>
  183. <?php
  184. // Set TZ so localtime works.
  185. date_default_timezone_set($tzstring);
  186. $now = localtime(time(), true);
  187. if ( $now['tm_isdst'] )
  188. _e('This timezone is currently in daylight saving time.');
  189. else
  190. _e('This timezone is currently in standard time.');
  191. ?>
  192. <br />
  193. <?php
  194. $allowed_zones = timezone_identifiers_list();
  195. if ( in_array( $tzstring, $allowed_zones) ) {
  196. $found = false;
  197. $date_time_zone_selected = new DateTimeZone($tzstring);
  198. $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
  199. $right_now = time();
  200. foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) {
  201. if ( $tr['ts'] > $right_now ) {
  202. $found = true;
  203. break;
  204. }
  205. }
  206. if ( $found ) {
  207. echo ' ';
  208. $message = $tr['isdst'] ?
  209. __('Daylight saving time begins on: <code>%s</code>.') :
  210. __('Standard time begins on: <code>%s</code>.');
  211. // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
  212. printf( $message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset']) ) );
  213. } else {
  214. _e('This timezone does not observe daylight saving time.');
  215. }
  216. }
  217. // Set back to UTC.
  218. date_default_timezone_set('UTC');
  219. ?>
  220. </span>
  221. <?php endif; ?>
  222. </td>
  223. </tr>
  224. <tr>
  225. <th scope="row"><?php _e('Date Format') ?></th>
  226. <td>
  227. <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
  228. <?php
  229. /**
  230. * Filter the default date formats.
  231. *
  232. * @since 2.7.0
  233. * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
  234. *
  235. * @param array $default_date_formats Array of default date formats.
  236. */
  237. $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
  238. $custom = true;
  239. foreach ( $date_formats as $format ) {
  240. echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='date_format' value='" . esc_attr($format) . "'";
  241. if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
  242. echo " checked='checked'";
  243. $custom = false;
  244. }
  245. echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
  246. }
  247. echo ' <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
  248. checked( $custom );
  249. echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( get_option('date_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('date_format') ) . "</span> <span class='spinner'></span>\n";
  250. ?>
  251. </fieldset>
  252. </td>
  253. </tr>
  254. <tr>
  255. <th scope="row"><?php _e('Time Format') ?></th>
  256. <td>
  257. <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
  258. <?php
  259. /**
  260. * Filter the default time formats.
  261. *
  262. * @since 2.7.0
  263. *
  264. * @param array $default_time_formats Array of default time formats.
  265. */
  266. $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) );
  267. $custom = true;
  268. foreach ( $time_formats as $format ) {
  269. echo "\t<label title='" . esc_attr($format) . "'><input type='radio' name='time_format' value='" . esc_attr($format) . "'";
  270. if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
  271. echo " checked='checked'";
  272. $custom = false;
  273. }
  274. echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
  275. }
  276. echo ' <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
  277. checked( $custom );
  278. echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( get_option('time_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('time_format') ) . "</span> <span class='spinner'></span>\n";
  279. echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.') . "</p>\n";
  280. ?>
  281. </fieldset>
  282. </td>
  283. </tr>
  284. <tr>
  285. <th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th>
  286. <td><select name="start_of_week" id="start_of_week">
  287. <?php
  288. for ($day_index = 0; $day_index <= 6; $day_index++) :
  289. $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';
  290. echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
  291. endfor;
  292. ?>
  293. </select></td>
  294. </tr>
  295. <?php do_settings_fields('general', 'default'); ?>
  296. <?php
  297. $languages = get_available_languages();
  298. $translations = wp_get_available_translations();
  299. if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
  300. $languages[] = WPLANG;
  301. }
  302. if ( ! empty( $languages ) || ! empty( $translations ) ) {
  303. ?>
  304. <tr>
  305. <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th>
  306. <td>
  307. <?php
  308. $locale = get_locale();
  309. if ( ! in_array( $locale, $languages ) ) {
  310. $locale = '';
  311. }
  312. wp_dropdown_languages( array(
  313. 'name' => 'WPLANG',
  314. 'id' => 'WPLANG',
  315. 'selected' => $locale,
  316. 'languages' => $languages,
  317. 'translations' => $translations,
  318. 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
  319. ) );
  320. // Add note about deprecated WPLANG constant.
  321. if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) {
  322. if ( is_super_admin() ) {
  323. ?>
  324. <p class="description">
  325. <strong><?php _e( 'Note:' ); ?></strong> <?php printf( __( 'The %s constant in your %s file is no longer needed.' ), '<code>WPLANG</code>', '<code>wp-config.php</code>' ); ?>
  326. </p>
  327. <?php
  328. }
  329. _deprecated_argument( 'define()', '4.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) );
  330. }
  331. ?>
  332. </td>
  333. </tr>
  334. <?php
  335. }
  336. ?>
  337. </table>
  338. <?php do_settings_sections('general'); ?>
  339. <?php submit_button(); ?>
  340. </form>
  341. </div>
  342. <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>