Make WordPress Core


Ignore:
Timestamp:
09/18/2007 10:23:16 PM (18 years ago)
Author:
markjaquith
Message:

Introducing wp_safe_redirect(). fixes #4606 for trunk

File:
1 edited

Legend:

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

    r6094 r6131  
    397397        header("Location: $location");
    398398    }
     399}
     400endif;
     401
     402if ( !function_exists('wp_safe_redirect') ) :
     403/**
     404 * performs a safe (local) redirect, using wp_redirect()
     405 * @return void
     406 **/
     407function wp_safe_redirect($location, $status = 302) {
     408    if ( $location{0} == '/' ) {
     409        if ( $location{1} == '/' )
     410            $location = get_option('home') . '/';
     411    } else {
     412        if ( substr($location, 0, strlen(get_option('home'))) != get_option('home') )
     413            $location = get_option('home') . '/';
     414    }
     415
     416    wp_redirect($location, $status);
    399417}
    400418endif;
Note: See TracChangeset for help on using the changeset viewer.