-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CANTINA-995: Disable crawling for VIP convenience domains #5129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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' ) ) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these check for the strings at the end of the Does any IPv4 or IPv6 need to be taken into account as potential values of |
||||||
$output = "# Crawling is blocked for go-vip.co and go-vip.net domains\n"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
$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' ); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WP must have loaded by this point to be able to use But, they still have chance to unhook it if they wish? Would be good to document an example of the right hook and process to run that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No customer application code should be loaded at this point yet. But yeah, @yolih, if you wanted to add this to documentation, that'd be fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
$_SERVER['HTTP_HOST']
set for curl requests?I see the nullcoalescing, but want to avoid customers making requests with curl and a browser on their convenience domain sites and getting different results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, unless the host parameter is set otherwise?