0

I have a problem with a plugin I developed that registers a shortcode. The shortcode returns a string with valid HTML but some themes seems to manipulate the HTML returned by the shortcode, and I really can't understand what is the reason.

For example, this is the correct output of my shortcode:

<div class="tile">
<a>
    <img src="0.jpg" />
    <div class="caption">
        <p>Kate</p>
    </div>
</a>
</div>

and this is the output I get with some theme:

<div class="tile">
<a>
    <img src="0.jpg" />
    <div class="caption">
        <p>Kate</p>
    </div>
</a>
</div>
<p></p></a></div>

As you can see there is some extra tag after the closing of the 'caption' DIV.

Maybe these themes apply some kind of HTML validation/sanitization?

5
  • What's the code you're using to generate the HTML (the function add_shortcode is using)? Jan 3, 2014 at 18:45
  • "some themes" namely?
    – Rarst
    Jan 3, 2014 at 18:45
  • Last theme was themeforest.net/item/… I can't post the code I use but is simply something like: $html = ""; $html .= "<div>"; ... $html .= "</div>; return $html; Jan 3, 2014 at 18:48
  • Does it happen with Twenty Fourteen? Or Twenty Thirteen?
    – s_ha_dum
    Jan 3, 2014 at 20:16
  • It doesn't happen with the TwentyFourteen nor with Twenty Thirteen, it happens with some other themes, like themeforest.net/item/… Jan 4, 2014 at 11:27

1 Answer 1

0

It looks like you are getting caught in some wpautop() replacements. Many people find the defualt WordPress wpautop() filter to be frustrating. So often in highly customized themes, there is a homegrown replacement.

For example, the theme you mentioned has a replacememt for some of the default WordPress filters. You can see a thread about it here... http://kaptinlin.com/support/discussion/1835/disable-automatic-p-tags/p1

The only recommendation I can make is to remove the clean formatting ( indents, newlines, etc. ) and see if that helps. Don't give the filters anything to wrap.

1
  • Thank you very much! I see the theme author suggests to edit the sources of the theme... I don't like that at all but at least I know what is the problem. Jan 4, 2014 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.