PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-admin/options-reading.php

https://github.com/shaiquddin/WordPress
PHP | 170 lines | 133 code | 18 blank | 19 comment | 16 complexity | c3b9526d68df2334ff4facf6d58b2464 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Reading settings administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( './admin.php' );
  10. if ( ! current_user_can( 'manage_options' ) )
  11. wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
  12. $title = __( 'Reading Settings' );
  13. $parent_file = 'options-general.php';
  14. /**
  15. * Display JavaScript on the page.
  16. *
  17. * @since 3.5.0
  18. */
  19. function options_reading_add_js() {
  20. ?>
  21. <script type="text/javascript">
  22. //<![CDATA[
  23. jQuery(document).ready(function($){
  24. var section = $('#front-static-pages'),
  25. staticPage = section.find('input:radio[value="page"]'),
  26. selects = section.find('select'),
  27. check_disabled = function(){
  28. selects.prop( 'disabled', ! staticPage.prop('checked') );
  29. };
  30. check_disabled();
  31. section.find('input:radio').change(check_disabled);
  32. });
  33. //]]>
  34. </script>
  35. <?php
  36. }
  37. add_action('admin_head', 'options_reading_add_js');
  38. /**
  39. * Render the blog charset setting.
  40. *
  41. * @since 3.5.0
  42. */
  43. function options_reading_blog_charset() {
  44. echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
  45. echo '<p class="description">' . __( 'The <a href="http://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
  46. }
  47. get_current_screen()->add_help_tab( array(
  48. 'id' => 'overview',
  49. 'title' => __('Overview'),
  50. 'content' => '<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
  51. '<p>' . sprintf(__('You can choose what&#8217;s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two <a href="%s">Pages</a>. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '</p>' .
  52. '<p>' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display and whether to show full text or a summary.') . '</p>' .
  53. '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
  54. ) );
  55. get_current_screen()->add_help_tab( array(
  56. 'id' => 'site-visibility',
  57. 'title' => has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ),
  58. '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 radio button next to &#8220;Ask search engines not to index 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>' .
  59. '<p>' . __( 'When this setting is in effect a reminder is shown in the Right Now box of the Dashboard that says, &#8220;Search Engines Discouraged,&#8221; to remind you that your site is not being crawled.' ) . '</p>',
  60. ) );
  61. get_current_screen()->set_help_sidebar(
  62. '<p><strong>' . __('For more information:') . '</strong></p>' .
  63. '<p>' . __('<a href="http://codex.wordpress.org/Settings_Reading_Screen" target="_blank">Documentation on Reading Settings</a>') . '</p>' .
  64. '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  65. );
  66. include( './admin-header.php' );
  67. ?>
  68. <div class="wrap">
  69. <?php screen_icon(); ?>
  70. <h2><?php echo esc_html( $title ); ?></h2>
  71. <form method="post" action="options.php">
  72. <?php
  73. settings_fields( 'reading' );
  74. if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
  75. add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
  76. ?>
  77. <?php if ( ! get_pages() ) : ?>
  78. <input name="show_on_front" type="hidden" value="posts" />
  79. <table class="form-table">
  80. <?php
  81. if ( 'posts' != get_option( 'show_on_front' ) ) :
  82. update_option( 'show_on_front', 'posts' );
  83. endif;
  84. else :
  85. if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
  86. update_option( 'show_on_front', 'posts' );
  87. ?>
  88. <table class="form-table">
  89. <tr valign="top">
  90. <th scope="row"><?php _e( 'Front page displays' ); ?></th>
  91. <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
  92. <p><label>
  93. <input name="show_on_front" type="radio" value="posts" class="tog" <?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" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
  99. <?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
  100. </label>
  101. </p>
  102. <ul>
  103. <li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
  104. <li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
  105. </ul>
  106. <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
  107. <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
  108. <?php endif; ?>
  109. </fieldset></td>
  110. </tr>
  111. <?php endif; ?>
  112. <tr valign="top">
  113. <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
  114. <td>
  115. <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' ); ?>
  116. </td>
  117. </tr>
  118. <tr valign="top">
  119. <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
  120. <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>
  121. </tr>
  122. <tr valign="top">
  123. <th scope="row"><?php _e( 'For each article in a feed, show' ); ?> </th>
  124. <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each article in a feed, show' ); ?> </span></legend>
  125. <p><label><input name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Full text' ); ?></label><br />
  126. <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Summary' ); ?></label></p>
  127. </fieldset></td>
  128. </tr>
  129. <tr valign="top">
  130. <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </th>
  131. <td><fieldset><legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </span></legend>
  132. <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
  133. <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
  134. <label for="blog-public"><?php _e( 'Allow search engines to index this site' );?></label><br/>
  135. <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
  136. <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
  137. <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>
  138. <?php do_action('blog_privacy_selector'); ?>
  139. <?php else : ?>
  140. <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
  141. <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
  142. <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
  143. <?php endif; ?>
  144. </fieldset></td>
  145. </tr>
  146. <?php do_settings_fields( 'reading', 'default' ); ?>
  147. </table>
  148. <?php do_settings_sections( 'reading' ); ?>
  149. <?php submit_button(); ?>
  150. </form>
  151. </div>
  152. <?php include( './admin-footer.php' ); ?>