Created
March 11, 2013 12:41
-
-
Save fjaguero/5133974 to your computer and use it in GitHub Desktop.
Wordpress: Example Shortcode
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
/* @Workether ------------------------------------------------------------ | |
English price | |
--------------------------------------------------------------------------*/ | |
function price_shortcode( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'class' => 'price', | |
), $atts ) ); | |
$prefixblock = "block-price-"; | |
$class = $prefixblock.esc_attr($class); | |
if ($content == null) { | |
return '<div class="block-price"><span class="price price-text-request">Price on</span><span class="price price-request">Request</span></div>';} | |
else { | |
return '<div class="block-price ' . esc_attr($class) . '"><span class="price price-text">Prices start at</span><span class="price price-number">' . $content . 'Sek</span></div>';} | |
} | |
add_shortcode( 'price', 'price_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment