WordPress.org

Make WordPress Core

Ticket #20060: 20060.diff

File 20060.diff, 1.0 KB (added by kurtpayne, 4 years ago)

wp_redirect_and_exit with a hook for testability

  • wp-includes/functions.php

     
    36543654        return $clean; 
    36553655} 
    36563656 
     3657/** 
     3658 * Redirects to another page. 
     3659 * 
     3660 * @since 1.5.1 
     3661 * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status. 
     3662 * 
     3663 * @param string $location The path to redirect to 
     3664 * @param int $status Status code to use 
     3665 * @return bool False if $location is not set 
     3666 */ 
     3667function wp_redirect_and_exit( $location, $status = 302 ) { 
     3668        wp_redirect( $location, $status ); 
     3669        $function = apply_filters( 'wp_after_redirect_handler', '_default_wp_after_redirect_handler' ); 
     3670        call_user_func( $function, $location, $status ); 
     3671} 
     3672 
     3673/** 
     3674 * Default after redirect handler.  Just exit. 
     3675 * @param string $location Location of redirected URL 
     3676 * @param string $status HTTP status code used for redirection  
     3677 */ 
     3678function _default_wp_after_redirect_handler( $location, $status ) { 
     3679        exit; 
     3680} 
     3681