cf_redirect

Perform a redirect using the best means possible.

Description

cf_redirect( (string) $location, (int) $status = 302 ); 

This is copypasted from Pods. Thanks Pods! Very GPL.

Parameters (2)

0. $location (string)
The path to redirect to.
1. $status — Optional. (int) => 302
Status code to use. Default is 302

Usage

  1. if ( !function_exists( 'cf_redirect' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-forms/includes/ajax.php'; 
  3.  
  4. // The path to redirect to. 
  5. $location = ''; 
  6.  
  7. // Optional. Status code to use. Default is 302 
  8. $status = 302; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = cf_redirect($location, $status); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/ajax.php  
  1. function cf_redirect( $location, $status = 302 ) { 
  2. if ( !headers_sent() ) { 
  3. wp_redirect( $location, $status ); 
  4. die(); 
  5. }else { 
  6. die( '<script type="text/javascript">' 
  7. . 'document.location = "' . str_replace( '&', '&', esc_js( $location ) ) . '";' 
  8. . '</script>' ); 
  9.