[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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  __DIR__ . '/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  // Used in the HTML title tag.
  20  $title       = __( 'General Settings' );
  21  $parent_file = 'options-general.php';
  22  /* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */
  23  $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
  24  
  25  add_action( 'admin_head', 'options_general_add_js' );
  26  
  27  $options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' .
  28      '<p>' . __( 'Most themes show the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. Many themes also show the tagline.' ) . '</p>';
  29  
  30  if ( ! is_multisite() ) {
  31      $options_help .= '<p>' . __( 'Two terms you will want to know are the WordPress URL and the site URL. The WordPress URL is where the core WordPress installation files are, and the site URL is the address a visitor uses in the browser to go to your site.' ) . '</p>' .
  32          '<p>' . sprintf(
  33              /* translators: %s: Documentation URL. */
  34              __( 'Though the terms refer to two different concepts, in practice, they can be the same address or different. For example, you can have the core WordPress installation files in the root directory (<code>https://example.com</code>), in which case the two URLs would be the same. Or the <a href="%s">WordPress files can be in a subdirectory</a> (<code>https://example.com/wordpress</code>). In that case, the WordPress URL and the site URL would be different.' ),
  35              __( 'https://developer.wordpress.org/advanced-administration/server/wordpress-in-directory/' )
  36          ) . '</p>' .
  37          '<p>' . sprintf(
  38              /* translators: 1: http://, 2: https:// */
  39              __( 'Both WordPress URL and site URL can start with either %1$s or %2$s. A URL starting with %2$s requires an SSL certificate, so be sure that you have one before changing to %2$s. With %2$s, a padlock will appear next to the address in the browser address bar. Both %2$s and the padlock signal that your site meets some basic security requirements, which can build trust with your visitors and with search engines.' ),
  40              '<code>http://</code>',
  41              '<code>https://</code>'
  42          ) . '</p>' .
  43          '<p>' . __( 'If you want site visitors to be able to register themselves, check the membership box. If you want the site administrator to register every new user, leave the box unchecked. In either case, you can set a default user role for all new users.' ) . '</p>';
  44  }
  45  
  46  $options_help .= '<p>' . __( 'You can set the language, and WordPress will automatically download and install the translation files (available if your filesystem is writable).' ) . '</p>' .
  47      '<p>' . __( 'UTC means Coordinated Universal Time.' ) . '</p>' .
  48      '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>';
  49  
  50  get_current_screen()->add_help_tab(
  51      array(
  52          'id'      => 'overview',
  53          'title'   => __( 'Overview' ),
  54          'content' => $options_help,
  55      )
  56  );
  57  
  58  get_current_screen()->set_help_sidebar(
  59      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  60      '<p>' . __( '<a href="https://wordpress.org/documentation/article/settings-general-screen/">Documentation on General Settings</a>' ) . '</p>' .
  61      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
  62  );
  63  
  64  require_once  ABSPATH . 'wp-admin/admin-header.php';
  65  ?>
  66  
  67  <div class="wrap">
  68  <h1><?php echo esc_html( $title ); ?></h1>
  69  
  70  <form method="post" action="options.php" novalidate="novalidate">
  71  <?php settings_fields( 'general' ); ?>
  72  
  73  <table class="form-table" role="presentation">
  74  
  75  <tr>
  76  <th scope="row"><label for="blogname"><?php _e( 'Site Title' ); ?></label></th>
  77  <td><input name="blogname" type="text" id="blogname" value="<?php form_option( 'blogname' ); ?>" class="regular-text" /></td>
  78  </tr>
  79  
  80  <?php
  81  if ( ! is_multisite() ) {
  82      /* translators: Site tagline. */
  83      $sample_tagline = __( 'Just another WordPress site' );
  84  } else {
  85      /* translators: %s: Network title. */
  86      $sample_tagline = sprintf( __( 'Just another %s site' ), get_network()->site_name );
  87  }
  88  $tagline_description = sprintf(
  89      /* translators: %s: Site tagline example. */
  90      __( 'In a few words, explain what this site is about. Example: &#8220;%s.&#8221;' ),
  91      $sample_tagline
  92  );
  93  ?>
  94  <tr>
  95  <th scope="row"><label for="blogdescription"><?php _e( 'Tagline' ); ?></label></th>
  96  <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option( 'blogdescription' ); ?>" class="regular-text" />
  97  <p class="description" id="tagline-description"><?php echo $tagline_description; ?></p></td>
  98  </tr>
  99  
 100  <?php if ( current_user_can( 'upload_files' ) ) : ?>
 101  <tr class="hide-if-no-js site-icon-section">
 102  <th scope="row"><?php _e( 'Site Icon' ); ?></th>
 103  <td>
 104      <?php
 105      wp_enqueue_media();
 106      wp_enqueue_script( 'site-icon' );
 107  
 108      $classes_for_upload_button = 'upload-button button-hero button';
 109      $classes_for_update_button = 'button';
 110      $classes_for_wrapper       = '';
 111  
 112      if ( has_site_icon() ) {
 113          $classes_for_wrapper         .= ' has-site-icon';
 114          $classes_for_button           = $classes_for_update_button;
 115          $classes_for_button_on_change = $classes_for_upload_button;
 116      } else {
 117          $classes_for_wrapper         .= ' hidden';
 118          $classes_for_button           = $classes_for_upload_button;
 119          $classes_for_button_on_change = $classes_for_update_button;
 120      }
 121  
 122      // Handle alt text for site icon on page load.
 123      $site_icon_id           = (int) get_option( 'site_icon' );
 124      $app_icon_alt_value     = '';
 125      $browser_icon_alt_value = '';
 126  
 127      $site_icon_url = get_site_icon_url();
 128  
 129      if ( $site_icon_id ) {
 130          $img_alt            = get_post_meta( $site_icon_id, '_wp_attachment_image_alt', true );
 131          $filename           = wp_basename( $site_icon_url );
 132          $app_icon_alt_value = sprintf(
 133              /* translators: %s: The selected image filename. */
 134              __( 'App icon preview: The current image has no alternative text. The file name is: %s' ),
 135              $filename
 136          );
 137  
 138          $browser_icon_alt_value = sprintf(
 139              /* translators: %s: The selected image filename. */
 140              __( 'Browser icon preview: The current image has no alternative text. The file name is: %s' ),
 141              $filename
 142          );
 143  
 144          if ( $img_alt ) {
 145              $app_icon_alt_value = sprintf(
 146                  /* translators: %s: The selected image alt text. */
 147                  __( 'App icon preview: Current image: %s' ),
 148                  $img_alt
 149              );
 150  
 151              $browser_icon_alt_value = sprintf(
 152                  /* translators: %s: The selected image alt text. */
 153                  __( 'Browser icon preview: Current image: %s' ),
 154                  $img_alt
 155              );
 156          }
 157      }
 158      ?>
 159  
 160      <style>
 161      :root {
 162          --site-icon-url: url( '<?php echo esc_url( $site_icon_url ); ?>' );
 163      }
 164      </style>
 165  
 166      <div id="site-icon-preview" class="site-icon-preview settings <?php echo esc_attr( $classes_for_wrapper ); ?>">
 167          <div class="direction-wrap">
 168              <img id="app-icon-preview" src="<?php echo esc_url( $site_icon_url ); ?>" class="app-icon-preview" alt="<?php echo esc_attr( $app_icon_alt_value ); ?>" />
 169              <div class="site-icon-preview-browser">
 170                  <svg role="img" aria-hidden="true" fill="none" xmlns="http://www.w3.org/2000/svg" class="browser-buttons"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 20a6 6 0 1 1 12 0 6 6 0 0 1-12 0Zm18 0a6 6 0 1 1 12 0 6 6 0 0 1-12 0Zm24-6a6 6 0 1 0 0 12 6 6 0 0 0 0-12Z" /></svg>
 171                  <div class="site-icon-preview-tab">
 172                      <img id="browser-icon-preview" src="<?php echo esc_url( $site_icon_url ); ?>" class="browser-icon-preview" alt="<?php echo esc_attr( $browser_icon_alt_value ); ?>" />
 173                      <div class="site-icon-preview-site-title" id="site-icon-preview-site-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></div>
 174                          <svg role="img" aria-hidden="true" fill="none" xmlns="http://www.w3.org/2000/svg" class="close-button">
 175                              <path d="M12 13.0607L15.7123 16.773L16.773 15.7123L13.0607 12L16.773 8.28772L15.7123 7.22706L12 10.9394L8.28771 7.22705L7.22705 8.28771L10.9394 12L7.22706 15.7123L8.28772 16.773L12 13.0607Z" />
 176                          </svg>
 177                      </div>
 178                  </div>
 179              </div>
 180          </div>
 181      </div>
 182  
 183      <input type="hidden" name="site_icon" id="site_icon_hidden_field" value="<?php form_option( 'site_icon' ); ?>" />
 184      <div class="site-icon-action-buttons">
 185          <button type="button"
 186              id="choose-from-library-button"
 187              class="<?php echo esc_attr( $classes_for_button ); ?>"
 188              data-alt-classes="<?php echo esc_attr( $classes_for_button_on_change ); ?>"
 189              data-size="512"
 190              data-choose-text="<?php esc_attr_e( 'Choose a Site Icon' ); ?>"
 191              data-update-text="<?php esc_attr_e( 'Change Site Icon' ); ?>"
 192              data-update="<?php esc_attr_e( 'Set as Site Icon' ); ?>"
 193              data-state="<?php echo esc_attr( has_site_icon() ); ?>"
 194  
 195          >
 196              <?php if ( has_site_icon() ) : ?>
 197                  <?php _e( 'Change Site Icon' ); ?>
 198              <?php else : ?>
 199                  <?php _e( 'Choose a Site Icon' ); ?>
 200              <?php endif; ?>
 201          </button>
 202          <button
 203              id="js-remove-site-icon"
 204              type="button"
 205              <?php echo has_site_icon() ? 'class="button button-secondary reset remove-site-icon"' : 'class="button button-secondary reset hidden"'; ?>
 206          >
 207              <?php _e( 'Remove Site Icon' ); ?>
 208          </button>
 209      </div>
 210  
 211      <p class="description">
 212          <?php
 213              printf(
 214                  /* translators: 1: pixel value for icon size. 2: pixel value for icon size. */
 215                  __( 'The Site Icon is what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. It should be square and at least <code>%1$s by %2$s</code> pixels.' ),
 216                  512,
 217                  512
 218              );
 219          ?>
 220      </p>
 221  
 222  </td>
 223  </tr>
 224  
 225      <?php
 226  endif;
 227      /* End Site Icon */
 228  
 229  if ( ! is_multisite() ) {
 230      $wp_site_url_class = '';
 231      $wp_home_class     = '';
 232      if ( defined( 'WP_SITEURL' ) ) {
 233          $wp_site_url_class = ' disabled';
 234      }
 235      if ( defined( 'WP_HOME' ) ) {
 236          $wp_home_class = ' disabled';
 237      }
 238      ?>
 239  
 240  <tr>
 241  <th scope="row"><label for="siteurl"><?php _e( 'WordPress Address (URL)' ); ?></label></th>
 242  <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>
 243  </tr>
 244  
 245  <tr>
 246  <th scope="row"><label for="home"><?php _e( 'Site Address (URL)' ); ?></label></th>
 247  <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; ?>" />
 248      <?php if ( ! defined( 'WP_HOME' ) ) : ?>
 249  <p class="description" id="home-description">
 250          <?php
 251          printf(
 252              /* translators: %s: Documentation URL. */
 253              __( 'Enter the same address here unless you <a href="%s">want your site home page to be different from your WordPress installation directory</a>.' ),
 254              __( 'https://developer.wordpress.org/advanced-administration/server/wordpress-in-directory/' )
 255          );
 256          ?>
 257  </p>
 258  <?php endif; ?>
 259  </td>
 260  </tr>
 261  
 262  <?php } ?>
 263  
 264  <tr>
 265  <th scope="row"><label for="new_admin_email"><?php _e( 'Administration Email Address' ); ?></label></th>
 266  <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" />
 267  <p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this, an email will be sent to your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
 268  <?php
 269  $new_admin_email = get_option( 'new_admin_email' );
 270  if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) {
 271      $pending_admin_email_message = sprintf(
 272          /* translators: %s: New admin email. */
 273          __( 'There is a pending change of the admin email to %s.' ),
 274          '<code>' . esc_html( $new_admin_email ) . '</code>'
 275      );
 276      $pending_admin_email_message .= sprintf(
 277          ' <a href="%1$s">%2$s</a>',
 278          esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
 279          __( 'Cancel' )
 280      );
 281      wp_admin_notice(
 282          $pending_admin_email_message,
 283          array(
 284              'additional_classes' => array( 'updated', 'inline' ),
 285          )
 286      );
 287  }
 288  ?>
 289  </td>
 290  </tr>
 291  
 292  <?php
 293  if ( ! is_multisite() ) {
 294      $membership_title = __( 'Membership' );
 295      ?>
 296  <tr>
 297  <th scope="row"><?php echo $membership_title; ?></th>
 298  <td><fieldset><legend class="screen-reader-text"><span><?php echo $membership_title; ?></span></legend><label for="users_can_register">
 299  <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> />
 300      <?php _e( 'Anyone can register' ); ?></label>
 301  </fieldset></td>
 302  </tr>
 303  
 304  <tr>
 305  <th scope="row"><label for="default_role"><?php _e( 'New User Default Role' ); ?></label></th>
 306  <td>
 307  <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select>
 308  </td>
 309  </tr>
 310  
 311      <?php
 312  }
 313  
 314  $languages    = get_available_languages();
 315  $translations = wp_get_available_translations();
 316  if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages, true ) ) {
 317      $languages[] = WPLANG;
 318  }
 319  if ( ! empty( $languages ) || ! empty( $translations ) ) {
 320      ?>
 321      <tr>
 322          <th scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?><span class="dashicons dashicons-translation" aria-hidden="true"></span></label></th>
 323          <td>
 324              <?php
 325              $locale = get_locale();
 326              if ( ! in_array( $locale, $languages, true ) ) {
 327                  $locale = '';
 328              }
 329  
 330              wp_dropdown_languages(
 331                  array(
 332                      'name'                        => 'WPLANG',
 333                      'id'                          => 'WPLANG',
 334                      'selected'                    => $locale,
 335                      'languages'                   => $languages,
 336                      'translations'                => $translations,
 337                      'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
 338                  )
 339              );
 340  
 341              // Add note about deprecated WPLANG constant.
 342              if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && WPLANG !== $locale ) {
 343                  _deprecated_argument(
 344                      'define()',
 345                      '4.0.0',
 346                      /* translators: 1: WPLANG, 2: wp-config.php */
 347                      sprintf( __( 'The %1$s constant in your %2$s file is no longer needed.' ), 'WPLANG', 'wp-config.php' )
 348                  );
 349              }
 350              ?>
 351          </td>
 352      </tr>
 353      <?php
 354  }
 355  ?>
 356  <tr>
 357  <?php
 358  $current_offset = get_option( 'gmt_offset' );
 359  $tzstring       = get_option( 'timezone_string' );
 360  
 361  $check_zone_info = true;
 362  
 363  // Remove old Etc mappings. Fallback to gmt_offset.
 364  if ( str_contains( $tzstring, 'Etc/GMT' ) ) {
 365      $tzstring = '';
 366  }
 367  
 368  if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
 369      $check_zone_info = false;
 370      if ( 0 === (int) $current_offset ) {
 371          $tzstring = 'UTC+0';
 372      } elseif ( $current_offset < 0 ) {
 373          $tzstring = 'UTC' . $current_offset;
 374      } else {
 375          $tzstring = 'UTC+' . $current_offset;
 376      }
 377  }
 378  
 379  ?>
 380  <th scope="row"><label for="timezone_string"><?php _e( 'Timezone' ); ?></label></th>
 381  <td>
 382  
 383  <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
 384      <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?>
 385  </select>
 386  
 387  <p class="description" id="timezone-description">
 388  <?php
 389      printf(
 390          /* translators: %s: UTC abbreviation */
 391          __( 'Choose either a city in the same timezone as you or a %s (Coordinated Universal Time) time offset.' ),
 392          '<abbr>UTC</abbr>'
 393      );
 394      ?>
 395  </p>
 396  
 397  <p class="timezone-info">
 398      <span id="utc-time">
 399      <?php
 400          printf(
 401              /* translators: %s: UTC time. */
 402              __( 'Universal time is %s.' ),
 403              '<code>' . date_i18n( $timezone_format, false, true ) . '</code>'
 404          );
 405          ?>
 406      </span>
 407  <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
 408      <span id="local-time">
 409      <?php
 410          printf(
 411              /* translators: %s: Local time. */
 412              __( 'Local time is %s.' ),
 413              '<code>' . date_i18n( $timezone_format ) . '</code>'
 414          );
 415      ?>
 416      </span>
 417  <?php endif; ?>
 418  </p>
 419  
 420  <?php if ( $check_zone_info && $tzstring ) : ?>
 421  <p class="timezone-info">
 422  <span>
 423      <?php
 424      $now = new DateTime( 'now', new DateTimeZone( $tzstring ) );
 425      $dst = (bool) $now->format( 'I' );
 426  
 427      if ( $dst ) {
 428          _e( 'This timezone is currently in daylight saving time.' );
 429      } else {
 430          _e( 'This timezone is currently in standard time.' );
 431      }
 432      ?>
 433      <br />
 434      <?php
 435      if ( in_array( $tzstring, timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) {
 436          $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
 437  
 438          // 0 index is the state at current time, 1 index is the next transition, if any.
 439          if ( ! empty( $transitions[1] ) ) {
 440              echo ' ';
 441              $message = $transitions[1]['isdst'] ?
 442                  /* translators: %s: Date and time. */
 443                  __( 'Daylight saving time begins on: %s.' ) :
 444                  /* translators: %s: Date and time. */
 445                  __( 'Standard time begins on: %s.' );
 446              printf(
 447                  $message,
 448                  '<code>' . wp_date( __( 'F j, Y' ) . ' ' . __( 'g:i a' ), $transitions[1]['ts'] ) . '</code>'
 449              );
 450          } else {
 451              _e( 'This timezone does not observe daylight saving time.' );
 452          }
 453      }
 454      ?>
 455      </span>
 456  </p>
 457  <?php endif; ?>
 458  </td>
 459  </tr>
 460  
 461  <?php $date_format_title = __( 'Date Format' ); ?>
 462  <tr>
 463  <th scope="row"><?php echo $date_format_title; ?></th>
 464  <td>
 465      <fieldset><legend class="screen-reader-text"><span><?php echo $date_format_title; ?></span></legend>
 466  <?php
 467      /**
 468       * Filters the default date formats.
 469       *
 470       * @since 2.7.0
 471       * @since 4.0.0 Replaced the `Y/m/d` format with `Y-m-d` (ISO date standard YYYY-MM-DD).
 472       * @since 6.8.0 Added the `d.m.Y` format.
 473       *
 474       * @param string[] $default_date_formats Array of default date formats.
 475       */
 476      $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y', 'd.m.Y' ) ) );
 477  
 478      $custom = true;
 479  
 480  foreach ( $date_formats as $format ) {
 481      echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
 482      if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
 483          echo " checked='checked'";
 484          $custom = false;
 485      }
 486      echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
 487  }
 488  
 489      echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
 490      checked( $custom );
 491      echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' .
 492              /* translators: Hidden accessibility text. */
 493              __( 'enter a custom date format in the following field' ) .
 494          '</span></span></label>' .
 495          '<label for="date_format_custom" class="screen-reader-text">' .
 496              /* translators: Hidden accessibility text. */
 497              __( 'Custom date format:' ) .
 498          '</label>' .
 499          '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" />' .
 500          '<br />' .
 501          '<p><strong>' . __( 'Preview:' ) . '</strong> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' .
 502          "<span class='spinner'></span>\n" . '</p>';
 503  ?>
 504      </fieldset>
 505  </td>
 506  </tr>
 507  
 508  <?php $time_format_title = __( 'Time Format' ); ?>
 509  <tr>
 510  <th scope="row"><?php echo $time_format_title; ?></th>
 511  <td>
 512      <fieldset><legend class="screen-reader-text"><span><?php echo $time_format_title; ?></span></legend>
 513  <?php
 514      /**
 515       * Filters the default time formats.
 516       *
 517       * @since 2.7.0
 518       *
 519       * @param string[] $default_time_formats Array of default time formats.
 520       */
 521      $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) );
 522  
 523      $custom = true;
 524  
 525  foreach ( $time_formats as $format ) {
 526      echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
 527      if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
 528          echo " checked='checked'";
 529          $custom = false;
 530      }
 531      echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
 532  }
 533  
 534      echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
 535      checked( $custom );
 536      echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' .
 537              /* translators: Hidden accessibility text. */
 538              __( 'enter a custom time format in the following field' ) .
 539          '</span></span></label>' .
 540          '<label for="time_format_custom" class="screen-reader-text">' .
 541              /* translators: Hidden accessibility text. */
 542              __( 'Custom time format:' ) .
 543          '</label>' .
 544          '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" />' .
 545          '<br />' .
 546          '<p><strong>' . __( 'Preview:' ) . '</strong> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' .
 547          "<span class='spinner'></span>\n" . '</p>';
 548  
 549      echo "\t<p class='date-time-doc'>" . __( '<a href="https://wordpress.org/documentation/article/customize-date-and-time-format/">Documentation on date and time formatting</a>.' ) . "</p>\n";
 550  ?>
 551      </fieldset>
 552  </td>
 553  </tr>
 554  <tr>
 555  <th scope="row"><label for="start_of_week"><?php _e( 'Week Starts On' ); ?></label></th>
 556  <td><select name="start_of_week" id="start_of_week">
 557  <?php
 558  /**
 559   * @global WP_Locale $wp_locale WordPress date and time locale object.
 560   */
 561  global $wp_locale;
 562  
 563  for ( $day_index = 0; $day_index <= 6; $day_index++ ) :
 564      $selected = ( (int) get_option( 'start_of_week' ) === $day_index ) ? 'selected="selected"' : '';
 565      echo "\n\t<option value='" . esc_attr( $day_index ) . "' $selected>" . $wp_locale->get_weekday( $day_index ) . '</option>';
 566  endfor;
 567  ?>
 568  </select></td>
 569  </tr>
 570  <?php do_settings_fields( 'general', 'default' ); ?>
 571  </table>
 572  
 573  <?php do_settings_sections( 'general' ); ?>
 574  
 575  <?php submit_button(); ?>
 576  </form>
 577  
 578  </div>
 579  
 580  <?php require_once  ABSPATH . 'wp-admin/admin-footer.php'; ?>


Generated : Fri Oct 10 08:20:03 2025 Cross-referenced by PHPXref