From f439ad856b8bf1e6a8abd9647b6edbb352b7fc0b Mon Sep 17 00:00:00 2001 From: Derek Smart Date: Thu, 26 Sep 2024 10:58:49 -0400 Subject: [PATCH] Blog Privacy: Don't add custom rules to wpcom robots.txt if blog_public=0 (#39468) * Don't clutter wpcom's robots.txt if blog_public=0. * changelog --- .../changelog/fix-blog-privacy-cluttering-wpcom-robots-txt | 4 ++++ .../src/features/blog-privacy/blog-privacy.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-blog-privacy-cluttering-wpcom-robots-txt 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(