Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mifrero opened this issue Mar 15, 2021 · 3 comments
Open

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

mifrero opened this issue Mar 15, 2021 · 3 comments

Comments

@mifrero
Copy link

mifrero commented Mar 15, 2021

Output source code:

<iframe loading="lazy" title="How to backup iPhone contacts to PC" width="500" height="281" src="https://www.youtube.com/embed/_Mer1KtiwpI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

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

@jorgemartine00
Copy link

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; }

@DahmaniAdame
Copy link

DahmaniAdame commented Apr 11, 2021

It's similar to this one - wp-media/wp-rocket#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.

@lkraav
Copy link

lkraav commented Apr 12, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants