Skip to content

Instantly share code, notes, and snippets.

@cdlewis
Created June 12, 2015 01:39
Show Gist options
  • Save cdlewis/7068ad258a3807406692 to your computer and use it in GitHub Desktop.
Save cdlewis/7068ad258a3807406692 to your computer and use it in GitHub Desktop.
Fix Tumblr
<?php
wp_oembed_remove_provider( '#https?://(.+)\.tumblr\.com/post/.*#i' );
wp_embed_register_handler( 'tumblr', '#https?://(.+)\.tumblr\.com/post/.*#i', function( $matches, $attr, $url, $rawattr ) {
$wp_oembed = _wp_oembed_get_object();
$args = '';
$provider = 'https://www.tumblr.com/oembed/1.0';
if( false === $data = $wp_oembed->fetch( $provider, $url, $args ) ) {
return false;
}
if( property_exists( $data, 'response' ) ) {
$data = json_decode( $data->response );
}
return apply_filters( 'oembed_result', $wp_oembed->data2html( $data, $url ), $url, $args );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment