Last active
December 11, 2015 22:09
-
-
Save intelliweb/4667990 to your computer and use it in GitHub Desktop.
Custom shortcode to add logout link with optional redirect URL and link text attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Custom shortcode to add logout link with optional redirect URL and link text attributes | |
// Defaults: [intw_logout redirect="HOME PAGE" text="Logout"] | |
add_shortcode( 'intw_logout', 'intw_logout_shortcode_func' ); | |
function intw_logout_shortcode_func( $atts ) { | |
$homepage = get_bloginfo('url'); | |
extract( shortcode_atts( array( | |
'redirect' => $homepage, | |
'text' => 'Logout', | |
), $atts ) ); | |
$content = '<a href="' . wp_logout_url( $redirect ) . '" title="Logout">' . $text . '</a>'; | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment