Making WordPress.org

Changeset 10564


Ignore:
Timestamp:
01/11/2021 01:43:43 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: When disabling RSS feeds, handle situations where redirect_canonical() has no canonical location for the request.

See [6855].
Fixes #5566.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r10507 r10564  
    14111411        if ( is_feed() ) {
    14121412            if ( isset( $_GET['feed'] ) ) {
    1413                 wp_redirect( esc_url_raw( remove_query_arg( 'feed' ) ), 301 );
     1413                wp_safe_redirect( esc_url_raw( remove_query_arg( 'feed' ) ), 301 );
    14141414                die();
    14151415            }
     1416
    14161417            set_query_var( 'feed', '' );
    1417             redirect_canonical();
     1418
     1419            if ( ! redirect_canonical() ) {
     1420                // There exists no canonical location for this request according to `redirect_canonical()`.
     1421                if ( get_query_var( 's' ) ) {
     1422                    wp_safe_redirect( home_url( '/search/' . get_query_var('s')  . '/' ), 301 );
     1423                } else {
     1424                    // If all else fails, homepage.
     1425                    wp_safe_redirect( home_url( '/' ) );
     1426                }
     1427            }
     1428
    14181429            die();
    14191430        }
Note: See TracChangeset for help on using the changeset viewer.