Last active
March 15, 2024 15:58
-
-
Save nextab/9e11fe516a30cc19dac3d1797ca6ab46 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function external_link_callback($atts, $content = null) { | |
$a = shortcode_atts([ | |
'link' => 'https://facebook.com', | |
], $atts); | |
if(is_user_logged_in()) { | |
return '<a href="' . $a['link'] . '" target="_blank" rel="noopener noreferrer">' . $content . '</a>'; | |
} else { | |
return '<a href="/wp-admin/" title="Einloggen">' . $content . '</a>'; | |
} | |
return; | |
} | |
add_shortcode('external_link', 'external_link_callback'); | |
/* Usage: | |
[external_link link="https://facebook.com"]Facebook[/external_link] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment