rocket-lazy-load icon indicating copy to clipboard operation
rocket-lazy-load copied to clipboard

Plugin create divs within p-tags if wpautop() is active

Open mifrero opened this issue 4 years ago • 3 comments

Output source code:

Browser output for users:

This behaviour creates unnecessary paragraphs and if the paragraphs are formatted in CSS with padding/margin, for example, this creates unsightly empty blocks for the user in the browser.

Example: https://iphone-tricks.com/tutorial/4028-whatsapp-how-to-use-bold-italic-and-strikethrough-text

Ticket on WP Rocket inbox: https://secure.helpscout.net/conversation/1451726245/247022?folderId=2952229

mifrero avatar Mar 15 '21 14:03 mifrero

client fixed the issue using the following snippet:

add_filter( 'the_content', 'removeParagraphsAroundIframes' ); function removeParagraphsAroundIframes( $content ) { $content = str_replace( [ '<p><iframe', '</iframe></p>' ], [ '<iframe', '</iframe>' ], $content ); return $content; }

jorgemartine00 avatar Apr 10 '21 18:04 jorgemartine00

It's similar to this one - https://github.com/wp-media/wp-rocket/issues/3716 A more efficient fix is to change our wrapper <div> to <span> with a display: block; property as mentioned on the issue (WP Rocket repo #3716). This will avoid extensive search/replace.

DahmaniAdame avatar Apr 11 '21 10:04 DahmaniAdame

All wpautop() stray p-tags are possibly related to everbug https://core.trac.wordpress.org/ticket/14050

Out of scientific interest, give this drop-in mu-plugin a shot https://core.trac.wordpress.org/attachment/ticket/14050/plugin.php

I'm still using it on all WP instances in my management.

With block-based content conversion, I think wpautop() deficiencies will eventually cease to be a problem, but for Classic mode the problem will persist basically forever.

lkraav avatar Apr 12 '21 10:04 lkraav