WordPress.org

Make WordPress Core


Ignore:
Timestamp:
06/02/2020 08:10:02 PM (20 months ago)
Author:
whyisjake
Message:

Comments: Ensure that unmoderated comments won't be search indexed.

After a comment is submitted, only allow a brief window where the comment is live on the site.

Fixes #49956.
Props: jonkolbert, ayeshrajans, Asif2BD, peterwilsoncc, imath, audrasjb, jonoaldersonwp, whyisjake.

File:
1 edited

Legend:

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

    r47855 r47887  
    405405        if ( is_user_logged_in() ) {
    406406            $headers = array_merge( $headers, wp_get_nocache_headers() );
     407        } elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
     408            // Unmoderated comments are only visible for one minute via the moderation hash.
     409            $headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + MINUTE_IN_SECONDS );
     410            $headers['Cache-Control'] = 'max-age=60, must-revalidate';
    407411        }
    408412        if ( ! empty( $this->query_vars['error'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.