Skip to content

Instantly share code, notes, and snippets.

@tomjn
Last active January 3, 2016 13:49
Show Gist options
  • Save tomjn/8471662 to your computer and use it in GitHub Desktop.
Save tomjn/8471662 to your computer and use it in GitHub Desktop.
Fixes oEmbedding tweets after Twitter's changes in Jan 2014. To use, download by clicking the "Download Gist" button below, upload to your WordPress site and activate. You will then need to re-save any posts edited or published since the 17 January.
{
"name": "cftp/twitteroembed-hotfix",
"description": "Fixes oEmbedding tweets after Twitter's changes in Jan 2014",
"license": "GPL-2.0+",
"type": "wordpress-plugin",
"authors": [
{
"name": "Tom J Nowell",
"email": "contact@tomjn.com",
"homepage": "http://tomjn.com"
},
{
"name" : "Code For The People",
"homepage": "http://codeforthepeople.com/"
}
],
"require": {
"composer/installers": "~1.0"
}
}
<?php
/*
Plugin Name: Twitter OEmbed Hotfix
Description: Fixes oEmbedding tweets after Twitter's changes in Jan 2014
Author: Tom J Nowell
Version: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_filter( 'oembed_providers', 'twitter_hotfix' );
function twitter_hotfix( $providers ) {
$providers['#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i'] = array( 'https://api.twitter.com/1/statuses/oembed.{format}', true );
return $providers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment