I have following shortcode:
function infobox_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'src' => '',
'title' => '',
'text' => '',
), $atts, 'infobox' ) );
$return = '<div class="infobox clearfix"><div class="col-md-1 infobox-image"><img src="'.$src.'" alt="'.$title.'"/></div><div class="col-md-8 infobox-content"><h2> ' . $title . '</h2><p>' . $text . '</p></div></div>';
return $return;
}
add_shortcode( 'infobox', 'infobox_shortcode' );
This works fine, when the user uses it simple like so:
[infobox src="http://www.google.com" title="Google" text="Some description"]
But:
As soon as the users tries to add e.g. a link with quotes to the shortcode, it - of course - breaks:
[infobox src="http://www.google.com" title="Google" text="Some description - see more: <a href="http://www.google.com">More here</a>"]
Issue is that my user uses the WP Editor to add a link and this makes double quotes. Alsor WordPress seems to delete single quotes for attributes by default and adds double quotes which then again break my shortcode.
Right now I see 2 solutions for this, but both are not quite satisfying.
a) Tell WP not to convert single quotes to double quotes in a href links while saving a post or b) To make the shortcode work with double quotes.
Any other hints or workarounds I can go with this?
Thanks!
Mike