From 62e8c2f9868315c699338e31d57f4edd664be0f5 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Sun, 5 Jan 2025 22:14:19 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@59576 git-svn-id: http://core.svn.wordpress.org/trunk@58962 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 8 +++++++- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 9eff6ecbeb..575e8a9175 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -366,7 +366,13 @@ add_action( 'after_switch_theme', '_wp_sidebars_changed' ); 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' ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 90302dc027..047cb22b17 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59575'; +$wp_version = '6.8-alpha-59576'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.