Created
August 8, 2013 20:27
-
-
Save hereswhatidid/6188365 to your computer and use it in GitHub Desktop.
Enable shortcode attribute override filter to a sample shortcode
This file contains 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('sample', 'sample_shortcode'); | |
function sample_shortcode($attr, $content = null) { | |
extract(shortcode_atts(array( | |
'title' => 'Hello, World!', | |
'testatt' => 'itworks' | |
), $attr, 'sample')); | |
return '<div style="border: 1px solid #333; border-radius: 10px; padding: 12px;"><h3>' . $title . '</h3>' . $content . '</div>'; | |
} | |
function override_sample_shortcode_title( $out, $pairs, $atts ) { | |
$out['title'] = 'Modified!'; | |
return $out; | |
} | |
add_filter( 'shortcode_atts_sample', 'override_sample_shortcode_title', 10, 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based off the explanation in this article: http://markjaquith.wordpress.com/2013/04/04/wordpress-36-shortcode-attribute-filter/