-
Notifications
You must be signed in to change notification settings - Fork 384
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
Remove registration of Facebook embed handler #4384
Conversation
$parent_node->removeChild( $script ); | ||
|
||
// Remove parent node if it is an empty <p> tag. | ||
if ( 'p' === $parent_node->tagName && null === $parent_node->firstChild ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script
tag is wrapped with a p
tag (from wpautop()
), so I've removed the lingering empty tag if it's there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unique just to Facebook or is it an issue shared across other embeds as well?
$parent_node->removeChild( $script ); | ||
|
||
// Remove parent node if it is an empty <p> tag. | ||
if ( 'p' === $parent_node->tagName && null === $parent_node->firstChild ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( 'p' === $parent_node->tagName && null === $parent_node->firstChild ) { | |
if ( 'p' === $parent_node->nodeName && null === $parent_node->firstChild ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at some of the other embeds, they are for the most part also wrapped with a <p>
tag. That isn't an issue per se, but if this PR is merged we should probably standardize the other embeds to not be wrapped with a paragraph element.
Co-Authored-By: Weston Ruter <[email protected]>
Humm, there are phpunit test errors. |
// Remove parent node if it is an empty <p> tag. | ||
if ( 'p' === $parent_node->nodeName && null === $parent_node->firstChild ) { | ||
$parent_node->parentNode->removeChild( $parent_node ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in c6869a9.
// Remove parent node if it is an empty <p> tag. | ||
if ( 'p' === $parent_node->nodeName && null === $parent_node->firstChild ) { | ||
$parent_node->parentNode->removeChild( $parent_node ); | ||
} | ||
} | ||
$fb_root->parentNode->removeChild( $fb_root ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that when you have multiple Facebook embeds on a page, each instance will include a div#fb-root
. So I suppose this should be changed to:
$fb_root->parentNode->removeChild( $fb_root ); | |
while ( $fb_root ) { | |
$fb_root->parentNode->removeChild( $fb_root ); | |
$fb_root = $dom->getElementById( 'fb-root' ); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this should work, but when it retrieves the #fb_root
div
again it's returning the same div
as before. I'll adapt this to use an XPath query instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it return the same div
as before if it was removed from the document?
Note: It appears Facebook tests don't have mocks for the non- |
Summary
This PR removes the custom WordPress embed handler for Facebook and instead relies on
\AMP_Facebook_Embed_Handler::sanitize_raw_embeds
to convert such embeds to their appropriate AMP components.Fixes #4358.
Checklist