Created
June 12, 2015 01:39
-
-
Save cdlewis/7068ad258a3807406692 to your computer and use it in GitHub Desktop.
Fix Tumblr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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