Permalink
Browse files

Introduce wp_no_robots(). Call it for pages that should never be inde…

…xed, regardless of blog privacy settings. Props nacin. fixes #19251

git-svn-id: http://svn.automattic.com/wordpress/trunk@19304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent 44e5c02 commit 45ddf08e078b67dee55c0fb069e0aad1a7562ee8 ryan committed Nov 15, 2011
@@ -157,7 +157,7 @@
<?php if ( apply_filters( 'enable_update_services_configuration', true ) ) { ?>
<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>
@@ -219,7 +219,7 @@
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 );
@@ -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() );
@@ -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 "<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
@@ -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();
View
@@ -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 "<meta name='robots' content='noindex,nofollow' />\n";
-}
-
if ( !is_multisite() ) {
wp_redirect( site_url('wp-login.php?action=register') );
die();

0 comments on commit 45ddf08

Please sign in to comment.