[wp-trac] [WordPress Trac] #34722: Open P Tag in shortcode related to h tag
WordPress Trac
noreply at wordpress.org
Wed Nov 18 07:32:05 UTC 2015
#34722: Open P Tag in shortcode related to h tag
--------------------------+-----------------------------
Reporter: BackuPs | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: TinyMCE | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hi Wordpress core Team
There is a bug in wordpress.
When you add a simple text in the editor like this
{{{
<h3>Integer in ex vel urna tempor ultrices.</h3> Morbi vehicula a orci nec
dignissim.
}}}
In the front of the website and in the page source code this text is
changed by wordpress to this and there are no issues or open or extra
p-tags.
{{{
<h3><p>Integer in ex vel urna tempor ultrices.</h3> <p>Morbi vehicula a
orci nec dignissim.</p>
}}}
[[Image(http://i.imgur.com/9TCF7gi.png)]]
However this does not happen in a shortcode
F.e. if you create a simple shortcode to add a div with a class around
your text. The result is open and or extra p-tags and break tags,
{{{#!php
<?php
function theme_shortcode_div($atts, $content = null, $code) {
$content = $content;
return '<div class="theme-div">' . $content .'</div>';
}
add_shortcode('theme_div', 'theme_shortcode_div');
}}}
And add the text within a sshortcode
{{{
[theme_div]<h3>Integer in ex vel urna tempor ultrices.</h3> Morbi vehicula
a orci nec dignissim. [/theme_div]
}}}
The same text is rendered like this.
{{{
<div class="theme-div"><br />
<h3>Integer in ex vel urna tempor ultrices.</h3>
<p> Morbi vehicula a orci nec dignissim. </div>
}}}
The p tag is never closed and before the h-tag there is suddenly a break
tag. I tested this in any of the default themes and i dont know how many
commercial themes and all with same results.
The p tag is left open and there is a extra break tag.
[[Image(http://i.imgur.com/52p291S.png)]]
It can even gets worse if you add it like this and embed your text in a
p-tag.
{{{
[theme_div]<h3><p>Integer in ex vel urna tempor ultrices.</h3> Morbi
vehicula a orci nec dignissim.</p> [/theme_div]
}}}
Now the end result is this
{{{
<div class="theme-div"><br />
<h3>
<p>Integer in ex vel urna tempor ultrices.</h3>
<p> Morbi vehicula a orci nec dignissim.</p>
<p> </div>
}}}
There is suddenly a extra br tag before the h-tag a extra p tag suddenly
in the h-tag and a extra p tag at the end of the div.
[[Image(http://i.imgur.com/J3597aM.png)]]
Note: All code has been added in text mode of the editor. The text was
added as shown. H-tag and normal text without any break tag all on one
line
Note: used theme in my images twenty sixteen.
Note: Shortcode added to the functions.php exactly as shown above.
Note: You can only see the p-tags missing in the source of the page. If
you inspect the page in firebug or chrome it shows the closing p-tags as
that is what browsers do. They try to close the p-tags by default even if
it is missing.
[[Image(http://i.imgur.com/aTwn2Wg.png)]]
Please resolve as this is a really annoying bug.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34722>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list