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

AMP custom elements are corrupted by force_balance_tags() #2156

Closed
andremacola opened this issue Apr 21, 2019 · 6 comments
Closed

AMP custom elements are corrupted by force_balance_tags() #2156

andremacola opened this issue Apr 21, 2019 · 6 comments

Comments

@andremacola
Copy link

andremacola commented Apr 21, 2019

When pasting a vídeo url on Gutenberg. The embed code do not validate with the Amp plugin. I am doing something wrong? I did not made any customization to the default wp block.

amp-video

Captura de Tela 2019-04-21 às 16 57 23

@westonruter
Copy link
Member

I've seen this issue come up before. It is an issue with force_balanced_tags() in WordPress core: https://wordpress.org/support/topic/how-to-enable-shortcodes-oembed-for-comments-in-amp-pages/#post-11427212

In short, the function is erroneously converting <amp-youtube... into <amp -youtube....

Notice the space being added. The AMP plugin then parses the document and comes across invalid amp tags.

Can you confirm you are applying this function to the_content?

If so, as a quick fix, you can remove the filter. Otherwise, you could adapt the code linked to in the gist linked to in the support forum topic above.

Ultimately, WordPress core needs to fix it's implementation of balanceTags to be aware of custom elements (which contain hyphens).

@andremacola
Copy link
Author

Thanks for the reply.

I'm not using this filter. Actually I am not using any filter in the_content but I am using a Multisite environment and I known Wordpress filter some security stuff in the_content when using MU.

@westonruter
Copy link
Member

Actually I am not using any filter in the_content but I am using a Multisite environment and I known Wordpress filter some security stuff in the_content when using MU.

@andremacola I checked and it doesn't seem that force_balance_tags() is being added in multisite. The symptom you are reporting sure seems to be the same, however. Can you try to identify which filter on the_content is causing the issue? Is has_filter( 'the_content', 'force_balance_tags' ) returning false on your setup where the_content() is called?

@andremacola
Copy link
Author

@westonruter You were right, some other developer did a very old commit using force_balance_tags to remove empty paragraphs. Can close the ticket

@westonruter
Copy link
Member

I'm going to leave this open for now to track getting a WordPress core fix for this, since it has come up twice now.

@westonruter westonruter reopened this Apr 22, 2019
@westonruter westonruter changed the title Gutenberg vídeo embed is not working AMP custom elements are corrupted by force_balance_tags() Apr 22, 2019
@westonruter
Copy link
Member

I filed a core ticket with the fix: https://core.trac.wordpress.org/ticket/47014

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

2 participants