[ 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 ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
  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  <table class="form-table" role="presentation">
  86  <tr>
  87  <th scope="row"><?php _e( 'Your homepage displays' ); ?></th>
  88  <td id="front-static-pages"><fieldset>
  89      <legend class="screen-reader-text"><span>
  90          <?php
  91          /* translators: Hidden accessibility text. */
  92          _e( 'Your homepage displays' );
  93          ?>
  94      </span></legend>
  95      <p><label>
  96          <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
  97          <?php _e( 'Your latest posts' ); ?>
  98      </label>
  99      </p>
 100      <p><label>
 101          <input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
 102          <?php
 103          printf(
 104              /* translators: %s: URL to Pages screen. */
 105              __( 'A <a href="%s">static page</a> (select below)' ),
 106              'edit.php?post_type=page'
 107          );
 108          ?>
 109      </label>
 110      </p>
 111  <ul>
 112      <li><label for="page_on_front">
 113      <?php
 114      printf(
 115          /* translators: %s: Select field to choose the front page. */
 116          __( 'Homepage: %s' ),
 117          wp_dropdown_pages(
 118              array(
 119                  'name'              => 'page_on_front',
 120                  'echo'              => 0,
 121                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 122                  'option_none_value' => '0',
 123                  'selected'          => get_option( 'page_on_front' ),
 124              )
 125          )
 126      );
 127      ?>
 128  </label></li>
 129      <li><label for="page_for_posts">
 130      <?php
 131      printf(
 132          /* translators: %s: Select field to choose the page for posts. */
 133          __( 'Posts page: %s' ),
 134          wp_dropdown_pages(
 135              array(
 136                  'name'              => 'page_for_posts',
 137                  'echo'              => 0,
 138                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 139                  'option_none_value' => '0',
 140                  'selected'          => get_option( 'page_for_posts' ),
 141              )
 142          )
 143      );
 144      ?>
 145  </label></li>
 146  </ul>
 147      <?php
 148      if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) :
 149          wp_admin_notice(
 150              __( '<strong>Warning:</strong> these pages should not be the same!' ),
 151              array(
 152                  'type'               => 'warning',
 153                  'id'                 => 'front-page-warning',
 154                  'additional_classes' => array( 'inline' ),
 155              )
 156          );
 157      endif;
 158      if ( get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_for_posts' ) || get_option( 'wp_page_for_privacy_policy' ) === get_option( 'page_on_front' ) ) :
 159          wp_admin_notice(
 160              __( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ),
 161              array(
 162                  'type'               => 'warning',
 163                  'id'                 => 'privacy-policy-page-warning',
 164                  'additional_classes' => array( 'inline' ),
 165              )
 166          );
 167      endif;
 168      ?>
 169  </fieldset></td>
 170  </tr>
 171  <?php endif; ?>
 172  <tr>
 173  <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
 174  <td>
 175  <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' ); ?>
 176  </td>
 177  </tr>
 178  <tr>
 179  <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
 180  <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>
 181  </tr>
 182  <tr>
 183  <th scope="row"><?php _e( 'For each post in a feed, include' ); ?> </th>
 184  <td><fieldset>
 185      <legend class="screen-reader-text"><span>
 186          <?php
 187          /* translators: Hidden accessibility text. */
 188          _e( 'For each post in a feed, include' );
 189          ?>
 190      </span></legend>
 191      <p>
 192          <label><input name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?>    /> <?php _e( 'Full text' ); ?></label><br />
 193          <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Excerpt' ); ?></label>
 194      </p>
 195      <p class="description">
 196          <?php
 197          printf(
 198              /* translators: %s: Documentation URL. */
 199              __( 'Your theme determines how content is displayed in browsers. <a href="%s">Learn more about feeds</a>.' ),
 200              __( 'https://developer.wordpress.org/advanced-administration/wordpress/feeds/' )
 201          );
 202          ?>
 203      </p>
 204  </fieldset></td>
 205  </tr>
 206  
 207  <tr class="option-site-visibility">
 208  <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?> </th>
 209  <td><fieldset>
 210      <legend class="screen-reader-text"><span>
 211          <?php
 212          has_action( 'blog_privacy_selector' )
 213              /* translators: Hidden accessibility text. */
 214              ? _e( 'Site visibility' )
 215              /* translators: Hidden accessibility text. */
 216              : _e( 'Search engine visibility' );
 217          ?>
 218      </span></legend>
 219  <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
 220      <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( '1', get_option( 'blog_public' ) ); ?> />
 221      <label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br />
 222      <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 223      <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 224      <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>
 225      <?php
 226      /**
 227       * Enables the legacy 'Site visibility' privacy options.
 228       *
 229       * By default the privacy options form displays a single checkbox to 'discourage' search
 230       * engines from indexing the site. Hooking to this action serves a dual purpose:
 231       *
 232       * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
 233       * 2. Open the door to adding additional radio button choices to the list.
 234       *
 235       * Hooking to this action also converts the 'Search engine visibility' heading to the more
 236       * open-ended 'Site visibility' heading.
 237       *
 238       * @since 2.1.0
 239       */
 240      do_action( 'blog_privacy_selector' );
 241      ?>
 242  <?php else : ?>
 243      <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 244      <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 245      <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
 246  <?php endif; ?>
 247  </fieldset></td>
 248  </tr>
 249  
 250  <?php do_settings_fields( 'reading', 'default' ); ?>
 251  </table>
 252  
 253  <?php do_settings_sections( 'reading' ); ?>
 254  
 255  <?php submit_button(); ?>
 256  </form>
 257  </div>
 258  <?php require_once  ABSPATH . 'wp-admin/admin-footer.php'; ?>


Generated : Thu Apr 25 08:20:02 2024 Cross-referenced by PHPXref