[wp-trac] [WordPress Trac] #34787: Extra P-Tag in shortcode content even if i use wpautop

WordPress Trac noreply at wordpress.org
Wed Nov 25 14:33:53 UTC 2015


#34787: Extra P-Tag in shortcode content even if i use wpautop
--------------------------+-----------------------------
 Reporter:  BackuPs       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Shortcodes    |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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
 <?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.

 [[Image(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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34787>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list