diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-blog-privacy-cluttering-wpcom-robots-txt b/projects/packages/jetpack-mu-wpcom/changelog/fix-blog-privacy-cluttering-wpcom-robots-txt new file mode 100644 index 0000000000000..82c4626b43381 --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-blog-privacy-cluttering-wpcom-robots-txt @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Blog Privacy: Do not add custom rules to wpcom's robots.txt if blog_public=0 diff --git a/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php b/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php index a9139489c1525..5f353aac93eaf 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php @@ -26,12 +26,12 @@ function robots_txt( string $output, $public ): string { $public = (int) $public; // If the site is completely private, don't bother with the additional restrictions. - if ( -1 === $public ) { + // For blog_public=0, WP.com Disallows all user agents and Core does not (relying on ). + // Let wpcom do it's thing to not clutter the robots.txt file. + if ( -1 === $public || ( 0 === $public && defined( 'IS_WPCOM' ) && IS_WPCOM ) ) { return $output; } - // For blog_public=0, WP.com Disallows all user agents and Core does not (relying on ). - // Always add Disallow blocks for blog_public=0 even on WP.com where it may be redundant. // An option oddly named because of history. if ( 0 === $public || get_option( 'wpcom_data_sharing_opt_out' ) ) { $ai_bots = array(