From 0cd4b7865ddb0a2e4fde74b2327f7f2209333d15 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 2 Jan 2025 09:55:42 +1100 Subject: [PATCH] Noindex unapproved comment previews. --- src/wp-includes/default-filters.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 9eff6ecbeb67a..575e8a91758f1 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -366,7 +366,13 @@ add_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' ); add_action( 'wp_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles(). -if ( isset( $_GET['replytocom'] ) ) { +if ( + // Comment reply link. + isset( $_GET['replytocom'] ) + || + // Unapproved comment preview. + ( isset( $_GET['unapproved'] ) && isset( $_GET['moderation-hash'] ) ) +) { add_filter( 'wp_robots', 'wp_robots_no_robots' ); }