Make WordPress Core

Changeset 6743


Ignore:
Timestamp:
02/06/2008 10:57:15 PM (17 years ago)
Author:
markjaquith
Message:

Allow redirect_canonical filter to cancel a redirect (just return FALSE). see #5766

File:
1 edited

Legend:

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

    r6726 r6743  
    188188    }
    189189
    190     if ( $redirect_url && $redirect_url != $requested_url ) {
    191         // var_dump($redirect_url); die();
    192         $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
    193         if ( $do_redirect) {
    194             // protect against chained redirects
    195             if ( !redirect_canonical($redirect_url, false) ) {
    196                 wp_redirect($redirect_url, 301);
    197                 exit();
    198             } else {
    199                 return false;
    200             }
     190    if ( !$redirect_url || $redirect_url == $requested_url )
     191        return false;
     192
     193    // Note that you can use the "redirect_canonical" filter to cancel a canonical redirect for whatever reason by returning FALSE
     194    $redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
     195
     196    if ( !$redirect_url || $redirect_url == $requested_url ) // yes, again -- in case the filter aborted the request
     197        return false;
     198
     199    if ( $do_redirect ) {
     200        // protect against chained redirects
     201        if ( !redirect_canonical($redirect_url, false) ) {
     202            wp_redirect($redirect_url, 301);
     203            exit();
    201204        } else {
    202             return $redirect_url;
     205            return false;
    203206        }
    204207    } else {
    205         return false;
     208        return $redirect_url;
    206209    }
    207210}
Note: See TracChangeset for help on using the changeset viewer.