Make WordPress Core

Changeset 59576


Ignore:
Timestamp:
01/05/2025 10:12:25 PM (9 days ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r59543 r59576  
    367367add_action( 'wp_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles().
    368368
    369 if ( isset( $_GET['replytocom'] ) ) {
     369if (
     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}
Note: See TracChangeset for help on using the changeset viewer.