[wp-trac] [WordPress Trac] #45495: Extra P tags added to custom dynamic blocks

WordPress Trac noreply at wordpress.org
Thu Dec 6 13:10:03 UTC 2018


#45495: Extra P tags added to custom dynamic blocks
--------------------------+-----------------------------
 Reporter:  mattheu       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 As requested - opening a ticket on Trac for
 https://github.com/WordPress/gutenberg/issues/12646

 I have a a custom block that is dynamic and rendered using the render
 callback.
 The custom block renders the excerpt.

 The render callback returns something like this:
 {{{#!php
 <div>
     <a href="http://example.com"><?php echo get_the_excerpt(); ?></a>
 </div>
 }}}

 Prior to Gutenberg 4.6 this worked as expected. After updating, I now get
 paragraph tags added around the link.

 Digging into this a bit - it seems the regression was caused by this
 change:
 https://github.com/WordPress/gutenberg/commit/2a66db0fc99a9fb1ba99f61e59e6a0b2a4a5f9ef
 #diff-6ff32417da0658502e7caa1a1abbeae6

 The key difference is the new code restores the `wpautop` filter at a
 later priority, which is still getting run.

 Digging into this some more - it is actually because `get_the_excerpt`
 internally calls `apply_filters( 'the_content' ` - which is a bit of a
 headache.

 There is a test case plugin on the github ticket to reproduce the bug.

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


More information about the wp-trac mailing list