Skip to content

Commit 938d27a

Browse files
committed
Comments: Noindex pages containing unapproved comments.
Adds a `noindex` directive to pages displaying a preview of an unapproved comment, ie pages with both an `approved` and `moderation-hash` parameter. This is to prevent the pages from appearing in search engines which can be the case if they ignore the canonical URL directive. Props peterwilsoncc, flixos90, joostdevalk. Fixes #62760. git-svn-id: https://develop.svn.wordpress.org/trunk@59576 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bb3f90f commit 938d27a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wp-includes/default-filters.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,13 @@
366366
add_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
367367
add_action( 'wp_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles().
368368

369-
if ( isset( $_GET['replytocom'] ) ) {
369+
if (
370+
// Comment reply link.
371+
isset( $_GET['replytocom'] )
372+
||
373+
// Unapproved comment preview.
374+
( isset( $_GET['unapproved'] ) && isset( $_GET['moderation-hash'] ) )
375+
) {
370376
add_filter( 'wp_robots', 'wp_robots_no_robots' );
371377
}
372378

0 commit comments

Comments
 (0)