Skip to content

Add Embed Preview support for classic embed providers#6345

Merged
pento merged 2 commits intomasterfrom
add/3499-proxy-embed-handlers
Apr 30, 2018
Merged

Add Embed Preview support for classic embed providers#6345
pento merged 2 commits intomasterfrom
add/3499-proxy-embed-handlers

Conversation

@pento
Copy link
Copy Markdown
Member

@pento pento commented Apr 23, 2018

Description

Before the magic of oEmbed, there was wp_embed_register_handler(). It was kind of hacky, but it was a forerunner for easy embedding we have today.

There are lots of plugins that still use it, however, so we should bring them into the Gutenberg-y future. This PR extends Embed Block previews to include classic embed providers.

Fixes #3499.

How has this been tested?

Tested with some plugins that use embeds.

Or:

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@pento pento added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience Core REST API Task Task for Core REST API efforts labels Apr 23, 2018
@pento pento added this to the 2.8 milestone Apr 23, 2018
@pento pento self-assigned this Apr 23, 2018
@pento pento requested review from a team and aaronjorbin April 23, 2018 06:22
lib/compat.php Outdated
}
}

if ( is_wp_error( $response ) || ! $local_oembed ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading correctly, couldn't this be an else to the above if ( $data ) {? The is_wp_error( $response ) || seems redundant with the previous condition, also wouldn't need the $local_oembed variable:

<?php

if ( is_wp_error( $response ) ) {
	// It's possibly a local post, so lets try and retrieve it that way.
	$post_id = url_to_postid( $_GET['url'] );
	$data    = get_oembed_response_data( $post_id, apply_filters( 'oembed_default_width', 600 ) );

	if ( $data ) {
		// It's a local post!
		$response = (object) $data;
	} else {
		global $wp_embed;
		$html = $wp_embed->shortcode( array(), $_GET['url'] );
		if ( $html ) {
			return array(
				'provider_name' => __( 'Embed Handler', 'gutenberg' ),
				'html'          => $html,
			);
		}
	}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I think it was a left over from a previous iteration of the code: I wasn't able to reproduce any issues after changing it.

pento and others added 2 commits April 30, 2018 14:28
@pento pento force-pushed the add/3499-proxy-embed-handlers branch from 9bcce91 to 7a3e933 Compare April 30, 2018 04:30
@pento pento merged commit 081f931 into master Apr 30, 2018
@pento pento deleted the add/3499-proxy-embed-handlers branch April 30, 2018 04:52
nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Jun 23, 2020
See WordPress/gutenberg#6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Jun 23, 2020
See WordPress/gutenberg#6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 23, 2020
See WordPress/gutenberg#6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 

Built from https://develop.svn.wordpress.org/trunk@48135


git-svn-id: http://core.svn.wordpress.org/trunk@47904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Jun 23, 2020
See WordPress/gutenberg#6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 

Built from https://develop.svn.wordpress.org/trunk@48135


git-svn-id: https://core.svn.wordpress.org/trunk@47904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
donmhico pushed a commit to donmhico/wordpress-develop that referenced this pull request Jun 26, 2020
See WordPress/gutenberg#6345

Fixes #45447.

Props swisspidy, pento, audrasjb, aduth, jrchamp, thrijith, TimothyBlynJacobs, whyisjake. 
 


git-svn-id: https://develop.svn.wordpress.org/trunk@48135 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core REST API Task Task for Core REST API efforts [Feature] Extensibility The ability to extend blocks or the editing experience [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants