| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 // Check whether the blog_privacy_selector action is in use, for later reuse. 20 $has_action_blog_privacy_selector = has_action( 'blog_privacy_selector' ); 21 22 add_action( 'admin_head', 'options_reading_add_js' ); 23 24 get_current_screen()->add_help_tab( 25 array( 26 'id' => 'overview', 27 'title' => __( 'Overview' ), 28 'content' => '<p>' . __( 'This screen contains the settings that affect the display of your content.' ) . '</p>' . 29 '<p>' . sprintf( 30 /* translators: %s: URL to create a new page. */ 31 __( 'You can choose what’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.' ), 32 'post-new.php?post_type=page' 33 ) . '</p>' . 34 '<p>' . sprintf( 35 /* translators: %s: Documentation URL. */ 36 __( '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>.' ), 37 __( 'https://developer.wordpress.org/advanced-administration/wordpress/feeds/' ) 38 ) . '</p>' . 39 '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>', 40 ) 41 ); 42 43 get_current_screen()->add_help_tab( 44 array( 45 'id' => 'site-visibility', 46 'title' => $has_action_blog_privacy_selector ? __( 'Site visibility' ) : __( 'Search engine visibility' ), 47 '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 “Discourage search engines from indexing this site” and click the Save Changes button at the bottom of the screen.' ) . '</p>' . 48 '<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>' . 49 '<p>' . __( 'When this setting is in effect, a reminder is shown in the At a Glance box of the Dashboard that says, “Search engines discouraged”, to remind you that you have directed search engines to not crawl your site.' ) . '</p>', 50 ) 51 ); 52 53 get_current_screen()->set_help_sidebar( 54 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 55 '<p>' . __( '<a href="https://wordpress.org/documentation/article/settings-reading-screen/">Documentation on Reading Settings</a>' ) . '</p>' . 56 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 57 ); 58 59 require_once ABSPATH . 'wp-admin/admin-header.php'; 60 ?> 61 62 <div class="wrap"> 63 <h1><?php echo esc_html( $title ); ?></h1> 64 65 <form method="post" action="options.php"> 66 <?php 67 settings_fields( 'reading' ); 68 69 if ( ! is_utf8_charset() ) { 70 add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) ); 71 } 72 ?> 73 74 <?php if ( ! get_pages() ) : ?> 75 <input name="show_on_front" type="hidden" value="posts" /> 76 <table class="form-table" role="presentation"> 77 <?php 78 if ( 'posts' !== get_option( 'show_on_front' ) ) : 79 update_option( 'show_on_front', 'posts' ); 80 endif; 81 82 else : 83 if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) { 84 update_option( 'show_on_front', 'posts' ); 85 } 86 87 $your_homepage_displays_title = __( 'Your homepage displays' ); 88 ?> 89 <table class="form-table" role="presentation"> 90 <tr> 91 <th scope="row"><?php echo $your_homepage_displays_title; ?></th> 92 <td id="front-static-pages"><fieldset> 93 <legend class="screen-reader-text"><span><?php echo $your_homepage_displays_title; ?></span></legend> 94 <p><label> 95 <input name="show_on_front" type="radio" value="posts" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> /> 96 <?php _e( 'Your latest posts' ); ?> 97 </label> 98 </p> 99 <p><label> 100 <input name="show_on_front" type="radio" value="page" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> /> 101 <?php 102 printf( 103 /* translators: %s: URL to Pages screen. */ 104 __( 'A <a href="%s">static page</a> (select below)' ), 105 'edit.php?post_type=page' 106 ); 107 ?> 108 </label> 109 </p> 110 <ul> 111 <li><label for="page_on_front"> 112 <?php 113 printf( 114 /* translators: %s: Select field to choose the front page. */ 115 __( 'Homepage: %s' ), 116 wp_dropdown_pages( 117 array( 118 'name' => 'page_on_front', 119 'echo' => 0, 120 'show_option_none' => __( '— Select —' ), 121 'option_none_value' => '0', 122 'selected' => get_option( 'page_on_front' ), 123 ) 124 ) 125 ); 126 ?> 127 </label></li> 128 <li><label for="page_for_posts"> 129 <?php 130 printf( 131 /* translators: %s: Select field to choose the page for posts. */ 132 __( 'Posts page: %s' ), 133 wp_dropdown_pages( 134 array( 135 'name' => 'page_for_posts', 136 'echo' => 0, 137 'show_option_none' => __( '— Select —' ), 138 'option_none_value' => '0', 139 'selected' => get_option( 'page_for_posts' ), 140 ) 141 ) 142 ); 143 ?> 144 </label></li> 145 </ul> 146 <?php 147 if ( 'page' === get_option( 'show_on_front' ) 148 && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) 149 ) : 150 wp_admin_notice( 151 __( '<strong>Warning:</strong> these pages should not be the same!' ), 152 array( 153 'type' => 'warning', 154 'id' => 'front-page-warning', 155 'additional_classes' => array( 'inline' ), 156 ) 157 ); 158 endif; 159 160 $privacy_policy_page = get_option( 'wp_page_for_privacy_policy' ); 161 162 if ( $privacy_policy_page 163 && ( get_option( 'page_for_posts' ) === $privacy_policy_page 164 || get_option( 'page_on_front' ) === $privacy_policy_page ) 165 ) : 166 wp_admin_notice( 167 __( '<strong>Warning:</strong> these pages should not be the same as your Privacy Policy page!' ), 168 array( 169 'type' => 'warning', 170 'id' => 'privacy-policy-page-warning', 171 'additional_classes' => array( 'inline' ), 172 ) 173 ); 174 endif; 175 ?> 176 </fieldset></td> 177 </tr> 178 <?php endif; ?> 179 <tr> 180 <th scope="row"><label for="posts_per_page"><?php _e( 'Number of recent posts shown on archive pages' ); ?></label></th> 181 <td> 182 <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" /> 183 </td> 184 </tr> 185 <tr> 186 <th scope="row"><label for="posts_per_rss"><?php _e( 'Number of recent items shown in syndication feeds' ); ?></label></th> 187 <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" /></td> 188 </tr> 189 190 <?php $rss_use_excerpt_title = __( 'For each post in a feed, include' ); ?> 191 <tr> 192 <th scope="row"><?php echo $rss_use_excerpt_title; ?> </th> 193 <td><fieldset aria-describedby="rss-use-excerpt-description"> 194 <legend class="screen-reader-text"><?php echo $rss_use_excerpt_title; ?></legend> 195 <input id="rss-use-full-text" name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?> /> 196 <label for="rss-use-full-text"><?php _e( 'Full text' ); ?></label><br /> 197 <input id="rss-use-excerpt" name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> 198 <label for="rss-use-excerpt"><?php _e( 'Excerpt' ); ?></label> 199 <p class="description" id="rss-use-excerpt-description"> 200 <?php 201 printf( 202 /* translators: %s: Documentation URL. */ 203 __( 'Your theme determines how content is displayed in browsers. <a href="%s">Learn more about feeds</a>.' ), 204 __( 'https://developer.wordpress.org/advanced-administration/wordpress/feeds/' ) 205 ); 206 ?> 207 </p> 208 </fieldset></td> 209 </tr> 210 211 <?php 212 $blog_privacy_selector_title = $has_action_blog_privacy_selector ? __( 'Site visibility' ) : __( 'Search engine visibility' ); 213 $fieldset_aria_describedby = $has_action_blog_privacy_selector ? ' aria-describedby="option-site-visibility-description"' : ''; 214 ?> 215 <tr class="option-site-visibility"> 216 <th scope="row"><?php echo $blog_privacy_selector_title; ?> </th> 217 <td><fieldset<?php echo $fieldset_aria_describedby; ?>> 218 <legend class="screen-reader-text"><span><?php echo $blog_privacy_selector_title; ?></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 id="option-site-visibility-description" class="description"><?php _e( 'Note: Neither of these options blocks access to your site — 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 <input name="blog_public" type="checkbox" id="blog_public" aria-describedby="option-site-visibility" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> /> 244 <label for="blog_public"><?php _e( 'Discourage search engines from indexing this site' ); ?></label> 245 <p id="option-site-visibility-description" 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'; ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Sep 28 08:20:31 2026 | Cross-referenced by PHPXref |