From 315f606306fc55e89ffc7ade968867125ee68a9e Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 25 Mar 2013 09:29:58 +0000 Subject: [PATCH] Fire the update_blog_public action from update_blog_status() instead of update_blog_public(). Pass blog ID and value to the action. Add code to noindex() to sync the 'public' value in the site options table with the blog_public value in the options table. fixes #23155 git-svn-id: https://develop.svn.wordpress.org/trunk@23794 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/general-template.php | 16 +++++++++++++++- wp-includes/ms-blogs.php | 2 ++ wp-includes/ms-functions.php | 4 +--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 89ebaeb2ea..fda738611f 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1703,8 +1703,22 @@ function wlwmanifest_link() { * @since 2.1.0 */ function noindex() { + $public = get_option( 'blog_public' ); + + if ( is_multisite() ) { + // Compare local and global and override with the local setting if they + // don't match. + + global $current_blog; + + if ( ( '' != $public ) && ( $public != $current_blog->public ) ) { + update_blog_status( get_current_blog_id(), 'public', $public ); + $current_blog->public = $public; + } + } + // If the blog is not public, tell robots to go away. - if ( '0' == get_option('blog_public') ) + if ( '0' == $public ) wp_no_robots(); } diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 85ab51c345..3280ed6464 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -695,6 +695,8 @@ function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) { ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); elseif ( 'deleted' == $pref ) ( $value == 1 ) ? do_action( 'make_delete_blog', $blog_id ) : do_action( 'make_undelete_blog', $blog_id ); + elseif ( 'public' == $pref ) + do_action( 'update_blog_public', $blog_id, $value ); // Moved here from update_blog_public(). return $value; } diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 5787f10d05..3b456fb2c0 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -1734,9 +1734,7 @@ function is_user_spammy( $user_login = null ) { * @return bool */ function update_blog_public( $old_value, $value ) { - global $wpdb; - do_action('update_blog_public'); - update_blog_status( $wpdb->blogid, 'public', (int) $value ); + update_blog_status( get_current_blog_id(), 'public', (int) $value ); } add_action('update_option_blog_public', 'update_blog_public', 10, 2);