Forked from kevinlisota/omit-twitter-script-oembed.php
Last active
August 29, 2015 14:24
-
-
Save sawant/cd9ed0428612605a47fb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function omit_twitter_script($provider, $url, $args) { | |
//get the hostname of the oEmbed endpoint provider being called | |
$host = parse_url($provider, PHP_URL_HOST); | |
//check to see that hostname is twitter.com | |
if (strpos($host, 'twitter.com') !== false) { | |
//adding ?omit_script=true to oEmbed endpoint call stops the returned HTML from containing widgets.js | |
$provider = add_query_arg('omit_script', 'true', $provider); | |
} | |
//return the $provider URL so the oEmbed can be fetched | |
return $provider; | |
} | |
add_filter('oembed_fetch_url', 'omit_twitter_script', 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment