shortcode_unautop()
in /wp-includes/formatting.php
is supposed to find shortcodes in a block of text and remove wrapping paragraph tags from them.
I’ve been having issues with paragraph tags making it through this process.
Here’s the output from var_dump($pee)
, which I placed at the very beginning of the function, i.e., the string before being processed:
string(353) "<p>[row wrap="true"]</p>
<p>[one_half]</p>
<p>[text_block]Fusce blandit adipiscing libero, nec bibendum diam volutpat tempor.[/text_block]</p>
<p>[/one_half]</p>
<p>[one_half last="true"]</p>
<p>[text_block]Donec fermentum diam leo, ut convallis nisl tristique ut. Ut rhoncus leo vitae tempus pulvinar.[/text_block]</p>
<p>[/one_half]</p>
<p>[/row]</p>
"
All wrapped in paragraph tags, as expected.
I then put var_dump(preg_replace( $pattern, '$1', $pee ));
just before the end of the function, which gives:
string(346) "[row wrap="true"]</p>
<p>[one_half]</p>
<p>[text_block]Fusce blandit adipiscing libero, nec bibendum diam volutpat tempor.[/text_block]</p>
<p>[/one_half]</p>
<p>[one_half last="true"]</p>
<p>[text_block]Donec fermentum diam leo, ut convallis nisl tristique ut. Ut rhoncus leo vitae tempus pulvinar.[/text_block]</p>
<p>[/one_half]</p>
<p>[/row]
"
All it has done is remove the opening and closing tags from the entire block, instead of each individual shortcode. I checked the value of global $shortcode_tags;
and all the shortcodes in my example were in it.
Is the function broken, or am I expecting too much from it? I’m pretty sure I’m not and it is supposed to remove all the paragraph tags – but I can’t help thinking something else is going on, like unexpected space characters or something.