[ Index ]

PHP Cross Reference of WordPress

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


Generated: Tue Oct 19 01:00:04 2021 Cross-referenced by PHPXref 0.7.1