Created
March 21, 2012 17:46
-
-
Save pdewouters/2150133 to your computer and use it in GitHub Desktop.
Registers a pricing_table 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
| add_filter( 'the_content', 'shortcode_unautop' ); | |
| // Register a new shortcode: [pricing_table] | |
| add_shortcode( 'pricing_table', 'cuj_pricing_table' ); | |
| add_shortcode('pricing_item', 'cuj_pricing_item'); | |
| // The callback function that will replace [pricing_table] | |
| function cuj_pricing_table($attr,$content) { | |
| $pricing_table = '<div class="pricing_table"><h4>' . $attr['title']. '</h4>' . do_shortcode($content) . '</div>'; | |
| return $pricing_table; | |
| } | |
| function cuj_pricing_item($attr){ | |
| $label = $attr['label']; | |
| $price = $attr['price']; | |
| $row = '<div class="pricing-row"><div class="pricing-label">' . $label . '</div>' . '<div class="pricing-price">' . $price . '</div></div>'; | |
| return $row; | |
| } | |
| // http://core.trac.wordpress.org/ticket/14050 - this bug adds br tags between shortcode outputs. | |
| // use br {display: none;} to fix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment