Make WordPress Core


Ignore:
Timestamp:
09/27/2015 10:10:08 PM (9 years ago)
Author:
wonderboymusic
Message:

Canonical: after [34272], don't redirect rewrite endpoints on attachment URLs when pretty permalinks are enabled.

Fixes #19918.

File:
1 edited

Legend:

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

    r34561 r34643  
    4040 */
    4141function redirect_canonical( $requested_url = null, $do_redirect = true ) {
    42     global $wp_rewrite, $is_IIS, $wp_query, $wpdb;
     42    global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
    4343
    4444    if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
     
    158158    } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) {
    159159        // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
    160         if ( is_attachment() && ! $redirect_url ) {
     160        if ( is_attachment() &&
     161            ! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) &&
     162            ! $redirect_url ) {
    161163            if ( ! empty( $_GET['attachment_id'] ) ) {
    162164                $redirect_url = get_attachment_link( get_query_var( 'attachment_id' ) );
Note: See TracChangeset for help on using the changeset viewer.