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
This commit is contained in:
Peter Wilson 2025-01-05 22:14:19 +00:00
parent e86f173f45
commit 62e8c2f986
2 changed files with 8 additions and 2 deletions

View File

@ -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' );
}

View File

@ -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.