Introduce wp_no_robots(). Call it for pages that should never be indexed, regardless of blog privacy settings. Props nacin. fixes #19251

git-svn-id: http://svn.automattic.com/wordpress/trunk@19304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-11-15 20:44:48 +00:00
parent 44e5c028b5
commit 45ddf08e07
6 changed files with 22 additions and 12 deletions

View File

@ -157,7 +157,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor
<?php if ( apply_filters( 'enable_update_services_configuration', true ) ) { ?> <?php if ( apply_filters( 'enable_update_services_configuration', true ) ) { ?>
<h3><?php _e('Update Services') ?></h3> <h3><?php _e('Update Services') ?></h3>
<?php if ( get_option('blog_public') ) : ?> <?php if ( 1 == get_option('blog_public') ) : ?>
<p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></label></p> <p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></label></p>

View File

@ -219,7 +219,7 @@ add_action( 'init', 'check_theme_switched', 99 );
add_action( 'after_switch_theme', '_wp_sidebars_changed' ); add_action( 'after_switch_theme', '_wp_sidebars_changed' );
if ( isset( $_GET['replytocom'] ) ) if ( isset( $_GET['replytocom'] ) )
add_filter( 'pre_option_blog_public', '__return_zero' ); add_action( 'wp_head', 'wp_no_robots' );
// Login actions // Login actions
add_action( 'login_head', 'wp_print_head_scripts', 9 ); add_action( 'login_head', 'wp_print_head_scripts', 9 );

View File

@ -1849,7 +1849,7 @@ function do_robots() {
$output = "User-agent: *\n"; $output = "User-agent: *\n";
$public = get_option( 'blog_public' ); $public = get_option( 'blog_public' );
if ( '0' == $public ) { if ( '0' == $public ) {
$output .= "Disallow: /\n"; $output .= "Disallow: /\n";
} else { } else {
$site_url = parse_url( site_url() ); $site_url = parse_url( site_url() );

View File

@ -1677,14 +1677,29 @@ function wlwmanifest_link() {
* Display a noindex meta tag if required by the blog configuration. * Display a noindex meta tag if required by the blog configuration.
* *
* If a blog is marked as not being public then the noindex meta tag will be * If a blog is marked as not being public then the noindex meta tag will be
* output to tell web robots not to index the page content. * output to tell web robots not to index the page content. Add this to the wp_head action.
* Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
*
* @see wp_no_robots
* *
* @since 2.1.0 * @since 2.1.0
*/ */
function noindex() { function noindex() {
// If the blog is not public, tell robots to go away. // If the blog is not public, tell robots to go away.
if ( '0' == get_option('blog_public') ) if ( '0' == get_option('blog_public') )
echo "<meta name='robots' content='noindex,nofollow' />\n"; wp_no_robots();
}
/**
* Display a noindex meta tag.
*
* Outputs a noindex meta tag that tells web robots not to index the page content.
* Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
*
* @since 3.3.0
*/
function wp_no_robots() {
echo "<meta name='robots' content='noindex,nofollow' />\n";
} }
/** /**

View File

@ -42,8 +42,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') {
global $error, $is_iphone, $interim_login, $current_site; global $error, $is_iphone, $interim_login, $current_site;
// Don't index any of these forms // Don't index any of these forms
add_filter( 'pre_option_blog_public', '__return_zero' ); add_action( 'login_head', 'wp_no_robots' );
add_action( 'login_head', 'noindex' );
if ( empty($wp_error) ) if ( empty($wp_error) )
$wp_error = new WP_Error(); $wp_error = new WP_Error();

View File

@ -3,7 +3,7 @@
/** Sets up the WordPress Environment. */ /** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' ); require( dirname(__FILE__) . '/wp-load.php' );
add_action( 'wp_head', 'signuppageheaders' ) ; add_action( 'wp_head', 'wp_no_robots' );
require( './wp-blog-header.php' ); require( './wp-blog-header.php' );
@ -17,10 +17,6 @@ function do_signup_header() {
} }
add_action( 'wp_head', 'do_signup_header' ); add_action( 'wp_head', 'do_signup_header' );
function signuppageheaders() {
echo "<meta name='robots' content='noindex,nofollow' />\n";
}
if ( !is_multisite() ) { if ( !is_multisite() ) {
wp_redirect( site_url('wp-login.php?action=register') ); wp_redirect( site_url('wp-login.php?action=register') );
die(); die();