Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sawant/cd9ed0428612605a47fb to your computer and use it in GitHub Desktop.
Save sawant/cd9ed0428612605a47fb to your computer and use it in GitHub Desktop.
<?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