[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/ -> options-general.php (source)

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


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7