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

FSE: oembeds do not work in block template parts #32330

Closed
johnstonphilip opened this issue May 28, 2021 · 1 comment · Fixed by #32331
Closed

FSE: oembeds do not work in block template parts #32330

johnstonphilip opened this issue May 28, 2021 · 1 comment · Fixed by #32331
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@johnstonphilip
Copy link
Contributor

Description

If you put a youtube video (or any oembed) into a block template part, it doesn't get embedded on the front end.

Step-by-step reproduction instructions

  1. Add a youtube video block to a block template part (like header.html)
  2. Add that block template part to index.html
  3. View the frontend, and notice the video was not embedded, but shows the youtube video URL only

Expected behaviour

The youtube video gets automatically embedded, like it does in a blog post.

Actual behaviour

The youtube video does not get embedded, but simply has the URL placed on the frontend in its place.

Screenshots or screen recording (optional)

Screen Shot 2021-05-28 at 3 24 35 PM

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: <10.7.1 |
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? No ( I am using a custom FSE theme)
@johnstonphilip
Copy link
Contributor Author

johnstonphilip commented May 28, 2021

The reason this happens is because template parts do not get filtered through the_content like normal posts do.

See this PR where block template parts are no longer filtered through the_content:
#20343

The problem is that oembeds are filtered to the_content in WordPress core here:
https://github.com/WordPress/WordPress/blob/270f2011f8ec7265c3f4ddce39c77ef5b496ed1c/wp-includes/class-wp-embed.php#L39

So the fix will likely need be to run $wp_embed->autoembed on block template parts, like what is done for widgets in core here:
https://github.com/WordPress/WordPress/blob/1314542c50e2ad2075b1304df20471febffb8fad/wp-includes/widgets/class-wp-widget-block.php#L77

@johnstonphilip johnstonphilip self-assigned this May 28, 2021
@johnstonphilip johnstonphilip added [Feature] Full Site Editing [Type] Bug An existing feature does not function as intended labels May 28, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant