[ 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  $title       = __( 'Reading Settings' );
  17  $parent_file = 'options-general.php';
  18  
  19  add_action( 'admin_head', 'options_reading_add_js' );
  20  
  21  get_current_screen()->add_help_tab(
  22      array(
  23          'id'      => 'overview',
  24          'title'   => __( 'Overview' ),
  25          'content' => '<p>' . __( 'This screen contains the settings that affect the display of your content.' ) . '</p>' .
  26              '<p>' . sprintf(
  27                  /* translators: %s: URL to create a new page. */
  28                  __( '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.' ),
  29                  'post-new.php?post_type=page'
  30              ) . '</p>' .
  31              '<p>' . sprintf(
  32                  /* translators: %s: Documentation URL. */
  33                  __( '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 a summary. <a href="%s">Learn more about feeds</a>.' ),
  34                  __( 'https://wordpress.org/support/article/wordpress-feeds/' )
  35              ) . '</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  );
  39  
  40  get_current_screen()->add_help_tab(
  41      array(
  42          'id'      => 'site-visibility',
  43          'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ),
  44          '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. Note that your privacy is not complete; your site is still visible on the web.' ) . '</p>' .
  45              '<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 your site is not being crawled.' ) . '</p>',
  46      )
  47  );
  48  
  49  get_current_screen()->set_help_sidebar(
  50      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  51      '<p>' . __( '<a href="https://wordpress.org/support/article/settings-reading-screen/">Documentation on Reading Settings</a>' ) . '</p>' .
  52      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  53  );
  54  
  55  require_once  ABSPATH . 'wp-admin/admin-header.php';
  56  ?>
  57  
  58  <div class="wrap">
  59  <h1><?php echo esc_html( $title ); ?></h1>
  60  
  61  <form method="post" action="options.php">
  62  <?php
  63  settings_fields( 'reading' );
  64  
  65  if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
  66      add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
  67  }
  68  ?>
  69  
  70  <?php if ( ! get_pages() ) : ?>
  71  <input name="show_on_front" type="hidden" value="posts" />
  72  <table class="form-table" role="presentation">
  73      <?php
  74      if ( 'posts' != get_option( 'show_on_front' ) ) :
  75          update_option( 'show_on_front', 'posts' );
  76      endif;
  77  
  78  else :
  79      if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
  80          update_option( 'show_on_front', 'posts' );
  81      }
  82      ?>
  83  <table class="form-table" role="presentation">
  84  <tr>
  85  <th scope="row"><?php _e( 'Your homepage displays' ); ?></th>
  86  <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Your homepage displays' ); ?></span></legend>
  87      <p><label>
  88          <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
  89          <?php _e( 'Your latest posts' ); ?>
  90      </label>
  91      </p>
  92      <p><label>
  93          <input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
  94          <?php
  95          printf(
  96              /* translators: %s: URL to Pages screen. */
  97              __( 'A <a href="%s">static page</a> (select below)' ),
  98              'edit.php?post_type=page'
  99          );
 100          ?>
 101      </label>
 102      </p>
 103  <ul>
 104      <li><label for="page_on_front">
 105      <?php
 106      printf(
 107          /* translators: %s: Select field to choose the front page. */
 108          __( 'Homepage: %s' ),
 109          wp_dropdown_pages(
 110              array(
 111                  'name'              => 'page_on_front',
 112                  'echo'              => 0,
 113                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 114                  'option_none_value' => '0',
 115                  'selected'          => get_option( 'page_on_front' ),
 116              )
 117          )
 118      );
 119      ?>
 120  </label></li>
 121      <li><label for="page_for_posts">
 122      <?php
 123      printf(
 124          /* translators: %s: Select field to choose the page for posts. */
 125          __( 'Posts page: %s' ),
 126          wp_dropdown_pages(
 127              array(
 128                  'name'              => 'page_for_posts',
 129                  'echo'              => 0,
 130                  'show_option_none'  => __( '&mdash; Select &mdash;' ),
 131                  'option_none_value' => '0',
 132                  'selected'          => get_option( 'page_for_posts' ),
 133              )
 134          )
 135      );
 136      ?>
 137  </label></li>
 138  </ul>
 139      <?php if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) : ?>
 140      <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
 141      <?php endif; ?>
 142      <?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' ) ) : ?>
 143      <div id="privacy-policy-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ); ?></p></div>
 144      <?php endif; ?>
 145  </fieldset></td>
 146  </tr>
 147  <?php endif; ?>
 148  <tr>
 149  <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
 150  <td>
 151  <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' ); ?>
 152  </td>
 153  </tr>
 154  <tr>
 155  <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
 156  <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>
 157  </tr>
 158  <tr>
 159  <th scope="row"><?php _e( 'For each post in a feed, include' ); ?> </th>
 160  <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each post in a feed, include' ); ?> </span></legend>
 161      <p>
 162          <label><input name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?>    /> <?php _e( 'Full text' ); ?></label><br />
 163          <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Summary' ); ?></label>
 164      </p>
 165      <p class="description">
 166          <?php
 167          printf(
 168              /* translators: %s: Documentation URL. */
 169              __( 'Your theme determines how content is displayed in browsers. <a href="%s">Learn more about feeds</a>.' ),
 170              __( 'https://wordpress.org/support/article/wordpress-feeds/' )
 171          );
 172          ?>
 173      </p>
 174  </fieldset></td>
 175  </tr>
 176  
 177  <tr class="option-site-visibility">
 178  <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </th>
 179  <td><fieldset><legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </span></legend>
 180  <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
 181      <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( '1', get_option( 'blog_public' ) ); ?> />
 182      <label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br/>
 183      <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 184      <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 185      <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>
 186      <?php
 187      /**
 188       * Enable the legacy 'Site Visibility' privacy options.
 189       *
 190       * By default the privacy options form displays a single checkbox to 'discourage' search
 191       * engines from indexing the site. Hooking to this action serves a dual purpose:
 192       * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
 193       * 2. Open the door to adding additional radio button choices to the list.
 194       *
 195       * Hooking to this action also converts the 'Search Engine Visibility' heading to the more
 196       * open-ended 'Site Visibility' heading.
 197       *
 198       * @since 2.1.0
 199       */
 200      do_action( 'blog_privacy_selector' );
 201      ?>
 202  <?php else : ?>
 203      <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
 204      <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
 205      <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
 206  <?php endif; ?>
 207  </fieldset></td>
 208  </tr>
 209  
 210  <?php do_settings_fields( 'reading', 'default' ); ?>
 211  </table>
 212  
 213  <?php do_settings_sections( 'reading' ); ?>
 214  
 215  <?php submit_button(); ?>
 216  </form>
 217  </div>
 218  <?php require_once  ABSPATH . 'wp-admin/admin-footer.php'; ?>


Generated : Tue May 26 08:20:01 2020 Cross-referenced by PHPXref