[wp-trac] [WordPress Trac] #49492: wpautop inserted p tags inconsistantly alter visual space

WordPress Trac noreply at wordpress.org
Sat Feb 22 17:09:49 UTC 2020


#49492: wpautop inserted p tags inconsistantly alter visual space
--------------------------+-----------------------------
 Reporter:  mesmer7       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.3.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I wrote a custom shortcode to insert a <figure></figure> in my posts.
 wpautop inserts an empty <p></p> before the <figure>.

 If I place the shortcode before the first paragraph after a subheading,
 the inserted <p> increases the visual space between the subheading and the
 paragraph. But if I place the shortcode before the second paragraph, the
 extra <p> doesn't affect the visual spacing between paragraphs.

 I can work around the inconsistency by changing wpautop's priority. But
 that scrambles other things on the web site.


 {{{

    remove_filter( 'the_content', 'wpautop' );
     add_filter('the_content', 'wpautop', 12);

 add_shortcode('hd_product', 'display_product');

 function display_product($args){

         extract(shortcode_atts(array(
                 'id' => null,
                 'cat' => null,
                 'tag' => null,
                 'orderby' => 'rand',
                 'limit' => 1,
                 ), $args));


                 $product = wc_get_product( $id );

                 $image =  $product->get_image($size = 'product-slider',
 ["class" => "product-callout-image","alt"=>"mp3 for sale"] );
                 $term = get_term_by( 'id',  $product->category_ids[0],
 'product_cat' );


                 $output = '<figure class="product-callout">';
                 $output .= '<a href="' . get_permalink($id) . '">' .
 $image ;
                 $output .= '<figcaption class="product-callout-
 caption"><b>' .  $term->name . '</b><br>' .  '$' . $product->price .
 '</figcaption>';
                 $output .=   '</a></figure>';

                 return $output;
 }

 }}}

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


More information about the wp-trac mailing list