Function
Filter the logout URL.
tml_filter_logout_url( string $url, string $redirect )
Parameters
-
$urlstring - The URL.
-
$redirectstring - The redirect.
Return
string
The logout URL.
Source
function tml_filter_logout_url( $url, $redirect ) {
// Bail if logout action doesn't exist for some reason
if ( ! tml_action_exists( 'logout' ) ) {
return $url;
}
// Get the logout URL
$url = tml_get_action_url( 'logout' );
// Add the redirect query argument if needed
if ( ! empty( $redirect ) ) {
$url = add_query_arg( 'redirect_to', urlencode( $redirect ), $url ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode -- matches wp_logout_url()'s own encoding of the redirect_to arg.
}
// Add the nonce
$url = wp_nonce_url( $url, 'log-out' );
return $url;
}
Uses
See also
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |