wp/wp-admin/options-reading.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once __DIR__ . '/admin.php';
    11 
    11 
    12 if ( ! current_user_can( 'manage_options' ) ) {
    12 if ( ! current_user_can( 'manage_options' ) ) {
    13 	wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    13 	wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    14 }
    14 }
    15 
    15 
    21 get_current_screen()->add_help_tab(
    21 get_current_screen()->add_help_tab(
    22 	array(
    22 	array(
    23 		'id'      => 'overview',
    23 		'id'      => 'overview',
    24 		'title'   => __( 'Overview' ),
    24 		'title'   => __( 'Overview' ),
    25 		'content' => '<p>' . __( 'This screen contains the settings that affect the display of your content.' ) . '</p>' .
    25 		'content' => '<p>' . __( 'This screen contains the settings that affect the display of your content.' ) . '</p>' .
    26 			'<p>' . sprintf( __( '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.' ), 'post-new.php?post_type=page' ) . '</p>' .
    26 			'<p>' . sprintf(
    27 			'<p>' . __( '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.' ) . '</p>' .
    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>' .
    28 			'<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
    36 			'<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>',
    29 	)
    37 	)
    30 );
    38 );
    31 
    39 
    32 get_current_screen()->add_help_tab(
    40 get_current_screen()->add_help_tab(
    33 	array(
    41 	array(
    34 		'id'      => 'site-visibility',
    42 		'id'      => 'site-visibility',
    35 		'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ),
    43 		'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site visibility' ) : __( 'Search engine visibility' ),
    36 		'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>' .
    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>' .
    37 			'<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>',
    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>',
    38 	)
    46 	)
    39 );
    47 );
    40 
    48 
    41 get_current_screen()->set_help_sidebar(
    49 get_current_screen()->set_help_sidebar(
    42 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    50 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    43 	'<p>' . __( '<a href="https://codex.wordpress.org/Settings_Reading_Screen">Documentation on Reading Settings</a>' ) . '</p>' .
    51 	'<p>' . __( '<a href="https://wordpress.org/support/article/settings-reading-screen/">Documentation on Reading Settings</a>' ) . '</p>' .
    44 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    52 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    45 );
    53 );
    46 
    54 
    47 include( ABSPATH . 'wp-admin/admin-header.php' );
    55 require_once ABSPATH . 'wp-admin/admin-header.php';
    48 ?>
    56 ?>
    49 
    57 
    50 <div class="wrap">
    58 <div class="wrap">
    51 <h1><?php echo esc_html( $title ); ?></h1>
    59 <h1><?php echo esc_html( $title ); ?></h1>
    52 
    60 
    53 <form method="post" action="options.php">
    61 <form method="post" action="options.php">
    54 <?php
    62 <?php
    55 settings_fields( 'reading' );
    63 settings_fields( 'reading' );
    56 
    64 
    57 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
    65 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
    58 	add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
    66 	add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
    59 }
    67 }
    60 ?>
    68 ?>
    61 
    69 
    62 <?php if ( ! get_pages() ) : ?>
    70 <?php if ( ! get_pages() ) : ?>
    66 	if ( 'posts' != get_option( 'show_on_front' ) ) :
    74 	if ( 'posts' != get_option( 'show_on_front' ) ) :
    67 		update_option( 'show_on_front', 'posts' );
    75 		update_option( 'show_on_front', 'posts' );
    68 	endif;
    76 	endif;
    69 
    77 
    70 else :
    78 else :
    71 	if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
    79 	if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
    72 		update_option( 'show_on_front', 'posts' );
    80 		update_option( 'show_on_front', 'posts' );
    73 	}
    81 	}
    74 	?>
    82 	?>
    75 <table class="form-table" role="presentation">
    83 <table class="form-table" role="presentation">
    76 <tr>
    84 <tr>
    81 		<?php _e( 'Your latest posts' ); ?>
    89 		<?php _e( 'Your latest posts' ); ?>
    82 	</label>
    90 	</label>
    83 	</p>
    91 	</p>
    84 	<p><label>
    92 	<p><label>
    85 		<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
    93 		<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
    86 		<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
    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 		?>
    87 	</label>
   101 	</label>
    88 	</p>
   102 	</p>
    89 <ul>
   103 <ul>
    90 	<li><label for="page_on_front">
   104 	<li><label for="page_on_front">
    91 	<?php
   105 	<?php
    92 	printf(
   106 	printf(
       
   107 		/* translators: %s: Select field to choose the front page. */
    93 		__( 'Homepage: %s' ),
   108 		__( 'Homepage: %s' ),
    94 		wp_dropdown_pages(
   109 		wp_dropdown_pages(
    95 			array(
   110 			array(
    96 				'name'              => 'page_on_front',
   111 				'name'              => 'page_on_front',
    97 				'echo'              => 0,
   112 				'echo'              => 0,
   104 	?>
   119 	?>
   105 </label></li>
   120 </label></li>
   106 	<li><label for="page_for_posts">
   121 	<li><label for="page_for_posts">
   107 	<?php
   122 	<?php
   108 	printf(
   123 	printf(
       
   124 		/* translators: %s: Select field to choose the page for posts. */
   109 		__( 'Posts page: %s' ),
   125 		__( 'Posts page: %s' ),
   110 		wp_dropdown_pages(
   126 		wp_dropdown_pages(
   111 			array(
   127 			array(
   112 				'name'              => 'page_for_posts',
   128 				'name'              => 'page_for_posts',
   113 				'echo'              => 0,
   129 				'echo'              => 0,
   118 		)
   134 		)
   119 	);
   135 	);
   120 	?>
   136 	?>
   121 </label></li>
   137 </label></li>
   122 </ul>
   138 </ul>
   123 	<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
   139 	<?php if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) === get_option( 'page_on_front' ) ) : ?>
   124 <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
   140 	<div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
   125 <?php endif; ?>
   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; ?>
   126 </fieldset></td>
   145 </fieldset></td>
   127 </tr>
   146 </tr>
   128 <?php endif; ?>
   147 <?php endif; ?>
   129 <tr>
   148 <tr>
   130 <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
   149 <th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
   135 <tr>
   154 <tr>
   136 <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
   155 <th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
   137 <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>
   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>
   138 </tr>
   157 </tr>
   139 <tr>
   158 <tr>
   140 <th scope="row"><?php _e( 'For each article in a feed, show' ); ?> </th>
   159 <th scope="row"><?php _e( 'For each post in a feed, include' ); ?> </th>
   141 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each article in a feed, show' ); ?> </span></legend>
   160 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each post in a feed, include' ); ?> </span></legend>
   142 <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 />
   161 	<p>
   143 <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Summary' ); ?></label></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>
   144 </fieldset></td>
   174 </fieldset></td>
   145 </tr>
   175 </tr>
   146 
   176 
   147 <tr class="option-site-visibility">
   177 <tr class="option-site-visibility">
   148 <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </th>
   178 <th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?> </th>
   149 <td><fieldset><legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </span></legend>
   179 <td><fieldset><legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site visibility' ) : _e( 'Search engine visibility' ); ?> </span></legend>
   150 <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
   180 <?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
   151 	<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( '1', get_option( 'blog_public' ) ); ?> />
   181 	<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( '1', get_option( 'blog_public' ) ); ?> />
   152 	<label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br/>
   182 	<label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br/>
   153 	<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
   183 	<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
   154 	<label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   184 	<label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
   155 	<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>
   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>
   156 	<?php
   186 	<?php
   157 	/**
   187 	/**
   158 	 * Enable the legacy 'Site Visibility' privacy options.
   188 	 * Enable the legacy 'Site visibility' privacy options.
   159 	 *
   189 	 *
   160 	 * By default the privacy options form displays a single checkbox to 'discourage' search
   190 	 * By default the privacy options form displays a single checkbox to 'discourage' search
   161 	 * engines from indexing the site. Hooking to this action serves a dual purpose:
   191 	 * engines from indexing the site. Hooking to this action serves a dual purpose:
   162 	 * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
   192 	 * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
   163 	 * 2. Open the door to adding additional radio button choices to the list.
   193 	 * 2. Open the door to adding additional radio button choices to the list.
   164 	 *
   194 	 *
   165 	 * Hooking to this action also converts the 'Search Engine Visibility' heading to the more
   195 	 * Hooking to this action also converts the 'Search engine visibility' heading to the more
   166 	 * open-ended 'Site Visibility' heading.
   196 	 * open-ended 'Site visibility' heading.
   167 	 *
   197 	 *
   168 	 * @since 2.1.0
   198 	 * @since 2.1.0
   169 	 */
   199 	 */
   170 	do_action( 'blog_privacy_selector' );
   200 	do_action( 'blog_privacy_selector' );
   171 	?>
   201 	?>
   183 <?php do_settings_sections( 'reading' ); ?>
   213 <?php do_settings_sections( 'reading' ); ?>
   184 
   214 
   185 <?php submit_button(); ?>
   215 <?php submit_button(); ?>
   186 </form>
   216 </form>
   187 </div>
   217 </div>
   188 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
   218 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>