I have a simple shortcode which takes an attribute and some content and returns an html block:
function testimonial($atts, $content = null) {
extract(shortcode_atts(array(
"by" => 'Joe'
), $atts));
return '<p class="testimonial">'.$content.'<br /><span>— '.$by.'</span></p>';
}
add_shortcode("testimonial", "testimonial");
and the poster can include a shortcode such as:
[testimonial by="Bob Smith"]This was great![/testimonial]
My question is, how to allow the user to insert simple html tags such as <b>
or <br/>
in their content, such as:
[testimonial by="Bob Smith"]Excellent restaurant.<br/>Try the desserts![/testimonial]
Since the function currently returns “content” as a string, the code displays.
You can allow your own interpretation of short codes, for example if user types
[b]
you can replace it in the output as<strong>
or<b>
. I.e.$content
can beThis is just rough example of the idea.