Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#34787 closed defect (bug) (duplicate)

Extra P-Tag in shortcode content even if i use wpautop

Reported by: backups's profile BackuPs Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Shortcodes Keywords:
Focuses: Cc:

Description

Hi

Please excuse me, but i have to repost a issue as apparently we dont get any confirmation or response for this bug/issue.

The original thread is listed here and not correctly answered and in my opinion waved away.

https://core.trac.wordpress.org/ticket/34722

When using a shortcode to create a div with a class around content and that content has a h-tag in it then after the h tag a open p tag is added and never closed. The suggestion using wpautop() function does not fix the issue but adds a empty close ptag before after the opening of the div and start of the h-tag.

Note: It does not happen when not using a shortcode and / or when the content within the shortcode does not have a h-tag

Try

[theme_div]<h3>Integer in ex vel urna tempor ultrices.</h3>Integer in ex vel urna tempor ultrices. Morbi vehicula a orci nec dignissim.[/theme_div]
<?php
function theme_shortcode_div($atts, $content = null, $code) {

        $content = do_shortcode($content);
        $content=wpautop( $content );
        return '<div class="theme-div">' . $content .'</div>';
}

add_shortcode('theme_div', 'theme_shortcode_div');

You will notice that the p-tags are close but i still get a empty p-tag -right before the h-tag and just after the div opens.... That should not be there at all. Moreover what if the text added also has advanced shortcodes to present a bloglist, portfolio grid, image grid etc. Calling then wpautop() could break the whole code. It is not a good solution i believe.

http://i.imgur.com/TLTW6bH.png

<div class="theme-div"><p></p>
<h3>Integer in ex vel urna tempor ultrices.</h3>
<p>Integer in ex vel urna tempor ultrices. Morbi vehicula a orci nec dignissim.</p>
</div>

Note: The result you see here is in the twenty-16 theme. The default wordpress theme.

Please provide a working solution.

Change History (1)

#1 @swissspidy
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #34722.

Please do not open a new ticket just because there was no answer to the previous one.

I'm sure some folks that know a bit about the Shortcode API will eventually reply. Maybe try asking around in #core after dev chat to increase the chance.

Note: See TracTickets for help on using tickets.