[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Reading settings administration panel.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** WordPress Administration Bootstrap */
  10  require_once  __DIR__ . '/admin.php';
  11  
  12  if ( ! current_user_can( 'manage_options' ) ) {
  13      wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
  14  }
  15  
  16  // Used in the HTML title tag.
  17  $title       = __( 'Reading Settings' );
  18  $parent_file = 'options-general.php';
  19  
  20  add_action( 'admin_head', 'options_reading_add_js' );
  21  
  22  get_current_screen()->add_help_tab(
  23      array(
  24          'id'      => 'overview',
  25          'title'   => __( 'Overview' ),
  26          'content' => '<p>' . __( 'This screen contains the settings that affect the display of your content.' ) . '</p>' .
  27              '<p>' . sprintf(
  28                  /* translators: %s: URL to create a new page. */
  29                  __( 'You can choose what&#8217;s displayed on the homepage of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static homepage, you first need to create two <a href="%s">Pages</a>. One will become the homepage, and the other will be where your posts are displayed.' ),
  30                  'post-new.php?post_type=page'
  31              ) . '</p>' .
  32              '<p>' . sprintf(
  33                  /* translators: %s: Documentation URL. */
  34                  __( 'You can also control the display of your content in RSS feeds, including the maximum number of posts to display and whether to show full text or an excerpt. <a href="%s">Learn more about feeds</a>.' ),
  35                  __( 'https://developer.wordpress.org/advanced-administration/wordpress/feeds/' )
  36              ) . '</p>' .
  37              '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
  38      )
  39  );
  40  
  41  get_current_screen()->add_help_tab(
  42      array(
  43          'id'      => 'site-visibility',
  44          'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site visibility' ) : __( 'Search engine visibility' ),
  45          'content' => '<p>' . __( 'You can choose whether or not your site will be crawled by robots, ping services, and spiders. If you want those services to ignore your site, click the checkbox next to &#8220;Discourage search engines from indexing this site&#8221; and click the Save Changes button at the bottom of the screen.' ) . '</p>' .
  46              '<p>' . __( 'Note that even when set to discourage search engines, your site is still visible on the web and not all search engines adhere to this directive.' ) . '</p>' .
  47              '<p>' . __( 'When this setting is in effect, a reminder is shown in the At a Glance box of the Dashboard that says, &#8220;Search engines discouraged&#8221;, to remind you that you have directed search engines to not crawl your site.' ) . '</p>',
  48      )
  49  );
  50  
  51  get_current_screen()->set_help_sidebar(
  52      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  53      '<p>' . __( '<a href="https://wordpress.org/documentation/article/settings-reading-screen/">Documentation on Reading Settings</a>' ) . '</p>' .
  54      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
  55  );
  56  
  57  require_once  ABSPATH . 'wp-admin/admin-header.php';
  58  ?>
  59  
  60  <div class="wrap">
  61  <h1><?php echo esc_html( $title ); ?></h1>
  62  
  63  <form method="post" action="options.php">
  64  <?php
  65  settings_fields( 'reading' );
  66  
  67  if ( ! is_utf8_charset() ) {
  68      add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
  69  }
  70  ?>
  71  
  72  <?php if ( ! get_pages() ) : ?>
  73  <input name="show_on_front" type="hidden" value="posts" />
  74  <table class="form-table" role="presentation">
  75      <?php
  76      if ( 'posts' !== get_option( 'show_on_front' ) ) :
  77          update_option( 'show_on_front', 'posts' );
  78      endif;
  79  
  80  else :
  81      if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
  82          update_option( 'show_on_front', 'posts' );
  83      }
  84  
  85      $your_homepage_displays_title = __( 'Your homepage displays' );
  86      ?>
  87  <table class="form-table" role="presentation">
  88  <tr>
  89  <th scope="row"><?php echo $your_homepage_displays_title; ?></th>
  90  <td id="front-static-pages"><fieldset>
  91      <legend class="screen-reader-text"><span><?php echo $your_homepage_displays_title; ?></span></legend>
  92      <p><label>
  93          <input name="show_on_front" type="radio" value="posts" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
  94          <?php _e( 'Your latest posts' ); ?>
  95      </label>
  96      </p>
  97      <p><label>
  98          <input name="show_on_front" type="radio" value="page" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
  99          <?php
 100          printf(
 101              /* translators: %s: URL to Pages screen. */
 102              __( 'A <a href="%s">static page</a> (select below)' ),
 103              'edit.php?post_type=page'
 104          );
 105          ?>
 106      </label>
 107      </p>
 108  <ul>
 109      <li><label for="page_on_front">
 110      <?php
 111      printf(
 112          /* translators: %s: Select field to choose the front page. */
 113          __( 'Homepage: %s' ),
 114          wp_dropdown_pages(
 115              array(
 116                  'name'              => 'page_on_front',
 117                  'echo'              => 0,
 118                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 119                  'option_none_value' => '0',
 120                  'selected'          => get_option( 'page_on_front' ),
 121              )
 122          )
 123      );
 124      ?>
 125  </label></li>
 126      <li><label for="page_for_posts">
 127      <?php
 128      printf(
 129          /* translators: %s: Select field to choose the page for posts. */
 130          __( 'Posts page: %s' ),
 131          wp_dropdown_pages(
 132              array(
 133                  'name'              => 'page_for_posts',
 134                  'echo'              => 0,
 135                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 136                  'option_none_value' => '0',
 137                  'selected'          => get_option( 'page_for_posts' ),
 138              )
 139          )
 140      );
 141      ?>
 142  </label></li>
 143  </ul>
 144      <?php
 145      if ( 'page' === get_option( 'show_on_front' )
 146          && get_option( 'page_for_posts' ) === get_option( 'page_on_front' )
 147      ) :
 148          wp_admin_notice(
 149              __( '<strong>Warning:</strong> these pages should not be the same!' ),
 150              array(
 151                  'type'               => 'warning',
 152                  'id'                 => 'front-page-warning',
 153                  'additional_classes' => array( 'inline' ),
 154              )
 155          );
 156      endif;
 157  
 158      $privacy_policy_page = get_option( 'wp_page_for_privacy_policy' );
 159  
 160      if ( $privacy_policy_page
 161          && ( get_option( 'page_for_posts' ) === $privacy_policy_page
 162              || get_option( 'page_on_front' ) === $privacy_policy_page )
 163      ) :
 164          wp_admin_notice(
 165              __( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ),
 166              array(
 167                  'type'               => 'warning',
 168                  'id'                 => 'privacy-policy-page-warning',
 169                  'additional_classes' => array( 'inline' ),
 170              )
 171          );
 172      endif;
 173      ?>
 174  </fieldset></td>
 175  </tr>
 176  <?php endif; ?>
 177  <tr>
 178  <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
 179  <td>
 180  <input name="posts_per_page" type="number" step="1" min="1" id="posts_per_page" value="<?php form_option( 'posts_per_page' ); ?>" class="small-text" /> <?php _e( 'posts' ); ?>
 181  </td>
 182  </tr>
 183  <tr>
 184  <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
 185  <td><input name="posts_per_rss" type="number" step="1" min="1" id="posts_per_rss" value="<?php form_option( 'posts_per_rss' ); ?>" class="small-text" /> <?php _e( 'items' ); ?></td>
 186  </tr>
 187  
 188  <?php $rss_use_excerpt_title = __( 'For each post in a feed, include' ); ?>
 189  <tr>
 190  <th scope="row"><?php echo $rss_use_excerpt_title; ?> </th>
 191  <td><fieldset>
 192      <legend class="screen-reader-text"><span><?php echo $rss_use_excerpt_title; ?></span></legend>
 193      <p>
 194          <label><input name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?>    /> <?php _e( 'Full text' ); ?></label><br />
 195          <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Excerpt' ); ?></label>
 196      </p>
 197      <p class="description">
 198          <?php
 199          printf(
 200              /* translators: %s: Documentation URL. */
 201              __( 'Your theme determines how content is displayed in browsers. <a href="%s">Learn more about feeds</a>.' ),
 202              __( 'https://developer.wordpress.org/advanced-administration/wordpress/feeds/' )
 203          );
 204          ?>
 205      </p>
 206  </fieldset></td>
 207  </tr>
 208  
 209  <?php $blog_privacy_selector_title = has_action( 'blog_privacy_selector' ) ? __( 'Site visibility' ) : __( 'Search engine visibility' ); ?>
 210  <tr class="option-site-visibility">
 211  <th scope="row"><?php echo $blog_privacy_selector_title; ?> </th>
 212  <td><fieldset>
 213      <legend class="screen-reader-text"><span><?php echo $blog_privacy_selector_title; ?></span></legend>
 214  <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
 215      <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( '1', get_option( 'blog_public' ) ); ?> />
 216      <label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br />
 217      <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 218      <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 219      <p class="description"><?php _e( 'Note: Neither of these options blocks access to your site &mdash; it is up to search engines to honor your request.' ); ?></p>
 220      <?php
 221      /**
 222       * Enables the legacy 'Site visibility' privacy options.
 223       *
 224       * By default the privacy options form displays a single checkbox to 'discourage' search
 225       * engines from indexing the site. Hooking to this action serves a dual purpose:
 226       *
 227       * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
 228       * 2. Open the door to adding additional radio button choices to the list.
 229       *
 230       * Hooking to this action also converts the 'Search engine visibility' heading to the more
 231       * open-ended 'Site visibility' heading.
 232       *
 233       * @since 2.1.0
 234       */
 235      do_action( 'blog_privacy_selector' );
 236      ?>
 237  <?php else : ?>
 238      <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 239      <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 240      <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
 241  <?php endif; ?>
 242  </fieldset></td>
 243  </tr>
 244  
 245  <?php do_settings_fields( 'reading', 'default' ); ?>
 246  </table>
 247  
 248  <?php do_settings_sections( 'reading' ); ?>
 249  
 250  <?php submit_button(); ?>
 251  </form>
 252  </div>
 253  <?php require_once  ABSPATH . 'wp-admin/admin-footer.php'; ?>


Generated : Fri May 1 08:20:13 2026 Cross-referenced by PHPXref