wp/wp-admin/options-reading.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 if ( ! current_user_can( 'manage_options' ) )
    12 if ( ! current_user_can( 'manage_options' ) )
    13 	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
    13 	wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    14 
    14 
    15 $title = __( 'Reading Settings' );
    15 $title = __( 'Reading Settings' );
    16 $parent_file = 'options-general.php';
    16 $parent_file = 'options-general.php';
    17 
    17 
    18 /**
       
    19  * Display JavaScript on the page.
       
    20  *
       
    21  * @since 3.5.0
       
    22  */
       
    23 function options_reading_add_js() {
       
    24 ?>
       
    25 <script type="text/javascript">
       
    26 	jQuery(document).ready(function($){
       
    27 		var section = $('#front-static-pages'),
       
    28 			staticPage = section.find('input:radio[value="page"]'),
       
    29 			selects = section.find('select'),
       
    30 			check_disabled = function(){
       
    31 				selects.prop( 'disabled', ! staticPage.prop('checked') );
       
    32 			};
       
    33 		check_disabled();
       
    34  		section.find('input:radio').change(check_disabled);
       
    35 	});
       
    36 </script>
       
    37 <?php
       
    38 }
       
    39 add_action('admin_head', 'options_reading_add_js');
    18 add_action('admin_head', 'options_reading_add_js');
    40 
       
    41 /**
       
    42  * Render the blog charset setting.
       
    43  *
       
    44  * @since 3.5.0
       
    45  */
       
    46 function options_reading_blog_charset() {
       
    47 	echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
       
    48 	echo '<p class="description">' . __( 'The <a href="https://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
       
    49 }
       
    50 
    19 
    51 get_current_screen()->add_help_tab( array(
    20 get_current_screen()->add_help_tab( array(
    52 	'id'      => 'overview',
    21 	'id'      => 'overview',
    53 	'title'   => __('Overview'),
    22 	'title'   => __('Overview'),
    54 	'content' => '<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
    23 	'content' => '<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
    55 		'<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>' .
    24 		'<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>' .
    56 		'<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>' .
    25 		'<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>' .
    57 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
    26 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
    58 ) );
    27 ) );
    59 
    28 
    60 get_current_screen()->add_help_tab( array(
    29 get_current_screen()->add_help_tab( array(
    61 	'id'      => 'site-visibility',
    30 	'id'      => 'site-visibility',
    64 		'<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>',
    33 		'<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>',
    65 ) );
    34 ) );
    66 
    35 
    67 get_current_screen()->set_help_sidebar(
    36 get_current_screen()->set_help_sidebar(
    68 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    37 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    69 	'<p>' . __('<a href="https://codex.wordpress.org/Settings_Reading_Screen" target="_blank">Documentation on Reading Settings</a>') . '</p>' .
    38 	'<p>' . __('<a href="https://codex.wordpress.org/Settings_Reading_Screen">Documentation on Reading Settings</a>') . '</p>' .
    70 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    39 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    71 );
    40 );
    72 
    41 
    73 include( ABSPATH . 'wp-admin/admin-header.php' );
    42 include( ABSPATH . 'wp-admin/admin-header.php' );
    74 ?>
    43 ?>
    75 
    44 
    76 <div class="wrap">
    45 <div class="wrap">
    77 <h2><?php echo esc_html( $title ); ?></h2>
    46 <h1><?php echo esc_html( $title ); ?></h1>
    78 
    47 
    79 <form method="post" action="options.php">
    48 <form method="post" action="options.php">
    80 <?php
    49 <?php
    81 settings_fields( 'reading' );
    50 settings_fields( 'reading' );
    82 
    51 
    96 	if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
    65 	if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
    97 		update_option( 'show_on_front', 'posts' );
    66 		update_option( 'show_on_front', 'posts' );
    98 ?>
    67 ?>
    99 <table class="form-table">
    68 <table class="form-table">
   100 <tr>
    69 <tr>
   101 <th scope="row"><?php _e( 'Front page displays' ); ?></th>
    70 <th scope="row"><?php _e( 'Your homepage displays' ); ?></th>
   102 <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
    71 <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Your homepage displays' ); ?></span></legend>
   103 	<p><label>
    72 	<p><label>
   104 		<input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
    73 		<input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
   105 		<?php _e( 'Your latest posts' ); ?>
    74 		<?php _e( 'Your latest posts' ); ?>
   106 	</label>
    75 	</label>
   107 	</p>
    76 	</p>
   109 		<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
    78 		<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
   110 		<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
    79 		<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
   111 	</label>
    80 	</label>
   112 	</p>
    81 	</p>
   113 <ul>
    82 <ul>
   114 	<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>
    83 	<li><label for="page_on_front"><?php printf( __( 'Homepage: %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>
   115 	<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>
    84 	<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>
   116 </ul>
    85 </ul>
   117 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
    86 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
   118 <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
    87 <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
   119 <?php endif; ?>
    88 <?php endif; ?>