Skip to content

YouTube wpcom_youtube_embed_crazy_url embed handler does not run anymore #46409

@kareldonk

Description

@kareldonk

Impacted plugin

Jetpack

Quick summary

Ever since the if ( ! defined( 'REST_API_REQUEST' ) ) { line got added in youtube.php the wpcom_youtube_embed_crazy_url hander does not get registered anymore, causing the YouTube embed by Jetpack not to work. The default embed implemented by WordPress then gets executed instead.

Because the Jetpack embed code does not get added and executed, the embed in the final content does not get wrapped with the Jetpack embed-youtube span.

https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/modules/shortcodes/youtube.php#L556C2-L556C42

Steps to reproduce

Create a post and add a bare YouTube link to it on its own separate line. Bare YouTube links in the post content should get embedded after running the the_content filters and the video should be in an iframe surrounded by the <span> added by Jetpack.

Final result should look like this in the generated HTML:

<span class="embed-youtube" ... ><iframe ... ></iframe></span>

However, due to the bug it looks like:

<iframe ... ></iframe>

Site owner impact

More than 60% of the total website/platform users

Severity

Moderate

What other impact(s) does this issue have?

No response

If a workaround is available, please outline it here.

Workaround is to add the following in functions.php of the theme:

function wpcom_youtube_embed_crazy_url_init2() {
	wp_embed_register_handler( 'wpcom_youtube_embed_crazy_url', '#https?://(?:www\.)?(?:youtube.com/(?:v/|playlist|watch[/\#?])|youtu\.be/).*#i', 'wpcom_youtube_embed_crazy_url' );
}
add_action( 'init', 'wpcom_youtube_embed_crazy_url_init2' );

Platform (Simple and/or Atomic)

Self-hosted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triageTicket needs to be triaged[Plugin] JetpackIssues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/[Pri] Normal[Status] Auto-allocated[Type] BugWhen a feature is broken and / or not performing as intended

    Type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions