Created
October 9, 2023 13:42
-
-
Save tcmulder/e4c4f92ce057c7c2206cce7307c3b0f3 to your computer and use it in GitHub Desktop.
WordPress Shortcode Starter
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
<?php | |
/** | |
* Add shortcode | |
*/ | |
add_shortcode( 'button', 'aqua_btn_shortcode' ); | |
function aqua_btn_shortcode( $attr, $content = "" ) { | |
extract( shortcode_atts( array( | |
'label' => 'Button', | |
'link' => '#', | |
'new_tab' => '', | |
'class' => '' | |
), $attr ) ); | |
$html = sprintf( | |
'<a href="%s"%s%s>%s</a>', | |
$link, | |
$new_tab ? ' target="_blank"' : '', | |
$class ? ' class="' . $class . '"' : '', | |
$label | |
); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment