Created
November 24, 2022 07:51
-
-
Save mikeott/9a10016297b4bacb4353546a8f15b63b to your computer and use it in GitHub Desktop.
Shortcode with attributes
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 /* | |
Shortcode CTA button for use in the editor. | |
Example usage: | |
[button href="https://www.google.com.au" target="_blank"]Visit Google[/button] | |
*/ | |
function button( $atts, $content = null ) { | |
$a = shortcode_atts( array( | |
'class' => 'button-link external', | |
'href' => '#', | |
'target' => '_self' | |
), $atts ); | |
return '<a class="' . esc_attr($a['class']) . '" href="' . esc_attr($a['href']) . '" target="' . esc_attr($a['target']) . '" >' . $content . '</a>'; | |
} | |
add_shortcode( 'button', 'button' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment