WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/23/2021 11:00:03 PM (4 weeks ago)
Author:
peterwilsoncc
Message:

Robots: Remove contradictory directive check in wp_robots().

Removes the mutually exclusive directives check in wp_robots(), ie allow both follow and nofollow to be specified and for archive and noarchive to be specified.

This fixes a bug in which WordPress would defer to the most permissive over the least permissive. When contradictory instructions are included, WordPress will defer to the search engine's or archivist's resolution policy: generally this is to observe the least, not most permissive.

Props Cybr, flixos90.
Fixes #52713.

File:
1 edited

Legend:

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

    r50371 r50566  
    1616 *
    1717 * @since 5.7.0
     18 * @since 5.7.1 No longer prevents specific directives to occur together.
    1819 */
    1920function wp_robots() {
     
    3031     */
    3132    $robots = apply_filters( 'wp_robots', array() );
    32 
    33     // Don't allow mutually exclusive directives.
    34     if ( ! empty( $robots['follow'] ) ) {
    35         unset( $robots['nofollow'] );
    36     }
    37     if ( ! empty( $robots['nofollow'] ) ) {
    38         unset( $robots['follow'] );
    39     }
    40     if ( ! empty( $robots['archive'] ) ) {
    41         unset( $robots['noarchive'] );
    42     }
    43     if ( ! empty( $robots['noarchive'] ) ) {
    44         unset( $robots['archive'] );
    45     }
    4633
    4734    $robots_strings = array();
Note: See TracChangeset for help on using the changeset viewer.