llms_redirect_and_exit( string $location, array $options = array() )
Redirect and exit
Description Description
Wrapper for WP core redirects which automatically calls exit();.
This function is redefined when running phpunit tests to make testing code that redirects (and exits).
Parameters Parameters
- $location
-
(string) (Required) Full URL to redirect to.
- $options
-
(array) (Optional) Array of options. Default is empty array.<br>
- 'status'
(int) HTTP status code of the redirect. Default:302.<br> - 'safe'
(bool) If true, usewp_safe_redirect()otherwise usewp_redirect(). Default:true.<br>
Default value: array()
- 'status'
Return Return
(void)
Source Source
File: includes/functions/llms-functions-wrappers.php
function llms_redirect_and_exit( $location, $options = array() ) {
$options = wp_parse_args(
$options,
array(
'status' => 302,
'safe' => true,
)
);
if ( 302 === $options['status'] ) {
nocache_headers(); // Prevent caching of redirects.
}
$func = $options['safe'] ? 'wp_safe_redirect' : 'wp_redirect';
$func( $location, $options['status'] );
exit();
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.4.0 | Added nocache_headers() to prevent caching of temporary redirects. |
| 5.3.0 | Moved location from includes/llms.functions.core.php. |
| 3.19.4 | Introduced. |