From 8fd58543f85150b3c38d724f4a43f03495e7077a Mon Sep 17 00:00:00 2001 From: Rebecca Hum Date: Fri, 5 Jan 2024 09:40:11 -0700 Subject: [PATCH] Disable crawling for VIP convenience domains (#5129) --- 001-core/privacy.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/001-core/privacy.php b/001-core/privacy.php index 213088e678b..ea7e47fb5e8 100644 --- a/001-core/privacy.php +++ b/001-core/privacy.php @@ -457,3 +457,22 @@ function delete_old_export_files() { } } } + +/** + * Disable crawling for go-vip.co and go-vip.net domains. + * + * @param string $output The robots.txt content. + * @return string The modified robots.txt content. + */ +function vip_convenience_domain_robots_txt( $output ) { + $host = strtolower( $_SERVER['HTTP_HOST'] ?? '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + if ( false !== strpos( $host, '.go-vip.co' ) || false !== strpos( $host, '.go-vip.net' ) ) { + $output = "# Crawling is blocked for go-vip.co and go-vip.net domains\n"; + $output .= "User-agent: *\n"; + $output .= "Disallow: /\n"; + } + + return $output; +} +// phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.robots_txt +add_filter( 'robots_txt', __NAMESPACE__ . '\vip_convenience_domain_robots_txt' );