Allow HTML tags in wordpress shortcode content?

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>&mdash; '.$by.'</span></p>';
}
add_shortcode("testimonial", "testimonial");

and the poster can include a shortcode such as:

Read More
[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.

Related posts

Leave a Reply

1 comment

  1. 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 be

    str_replace("[b]","<strong>", $content);
    

    This is just rough example of the idea.