Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix for twitter oembeds in WordPress
<?php
/**
* Plugin Name: Fix Twitter Oembed
*/
class FixTwitterOembed {
private static $twitter_oembed_regex = '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i';
public static function init() {
self::add_actions();
}
public static function add_actions() {
add_filter( 'oembed_providers', array( __CLASS__, 'fix_twitter_oembed' ) );
}
public static function fix_twitter_oembed( $providers ) {
if ( isset( $providers[self::$twitter_oembed_regex] ) ) {
$providers[self::$twitter_oembed_regex][0] = 'https://api.twitter.com/1/statuses/oembed.{format}';
}
return $providers;
}
}
FixTwitterOembed::init();
@jeremyescott

This comment has been minimized.

Copy link

jeremyescott commented Jan 16, 2014

I installed this and I didn't notice it work. Should this fix a 3.8 with just this plugin?

@jeffhester

This comment has been minimized.

Copy link

jeffhester commented Jan 19, 2014

I've got the same issue. Installed and activated on 3.8, but Twitter oEmbeds are still not working.

@jeffhester

This comment has been minimized.

Copy link

jeffhester commented Jan 19, 2014

Correction. It is working, but only after editing and re-saving a post. Weird?

@matthieumarechal

This comment has been minimized.

Copy link

matthieumarechal commented Feb 21, 2014

It is working for me too ! Very efficient ! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.