From 45ddf08e078b67dee55c0fb069e0aad1a7562ee8 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 15 Nov 2011 20:44:48 +0000 Subject: [PATCH] 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 --- wp-admin/options-writing.php | 2 +- wp-includes/default-filters.php | 2 +- wp-includes/functions.php | 2 +- wp-includes/general-template.php | 19 +++++++++++++++++-- wp-login.php | 3 +-- wp-signup.php | 6 +----- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php index 1dc164a34b..498b85caae 100644 --- a/wp-admin/options-writing.php +++ b/wp-admin/options-writing.php @@ -157,7 +157,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor

- +

diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index de18971390..16bb63d9ad 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -219,7 +219,7 @@ add_action( 'init', 'check_theme_switched', 99 ); add_action( 'after_switch_theme', '_wp_sidebars_changed' ); if ( isset( $_GET['replytocom'] ) ) - add_filter( 'pre_option_blog_public', '__return_zero' ); + add_action( 'wp_head', 'wp_no_robots' ); // Login actions add_action( 'login_head', 'wp_print_head_scripts', 9 ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 106122dd15..51f93ee803 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1849,7 +1849,7 @@ function do_robots() { $output = "User-agent: *\n"; $public = get_option( 'blog_public' ); - if ( '0' == $public ) { + if ( '0' == $public ) { $output .= "Disallow: /\n"; } else { $site_url = parse_url( site_url() ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 36dff4115b..24e8a4ef9b 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1677,14 +1677,29 @@ function wlwmanifest_link() { * 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 - * 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 */ function noindex() { // If the blog is not public, tell robots to go away. if ( '0' == get_option('blog_public') ) - echo "\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 "\n"; } /** diff --git a/wp-login.php b/wp-login.php index a61facc4f9..155f2ba912 100644 --- a/wp-login.php +++ b/wp-login.php @@ -42,8 +42,7 @@ function login_header($title = 'Log In', $message = '', $wp_error = '') { global $error, $is_iphone, $interim_login, $current_site; // Don't index any of these forms - add_filter( 'pre_option_blog_public', '__return_zero' ); - add_action( 'login_head', 'noindex' ); + add_action( 'login_head', 'wp_no_robots' ); if ( empty($wp_error) ) $wp_error = new WP_Error(); diff --git a/wp-signup.php b/wp-signup.php index 475d8cb5a4..6fa1742f0d 100644 --- a/wp-signup.php +++ b/wp-signup.php @@ -3,7 +3,7 @@ /** Sets up the WordPress Environment. */ require( dirname(__FILE__) . '/wp-load.php' ); -add_action( 'wp_head', 'signuppageheaders' ) ; +add_action( 'wp_head', 'wp_no_robots' ); require( './wp-blog-header.php' ); @@ -17,10 +17,6 @@ function do_signup_header() { } add_action( 'wp_head', 'do_signup_header' ); -function signuppageheaders() { - echo "\n"; -} - if ( !is_multisite() ) { wp_redirect( site_url('wp-login.php?action=register') ); die();