Last active
January 3, 2016 09:39
-
-
Save yurivictor/8444326 to your computer and use it in GitHub Desktop.
Fix for twitter oembeds in WordPress
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 | |
/** | |
* 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(); |
I've got the same issue. Installed and activated on 3.8, but Twitter oEmbeds are still not working.
Correction. It is working, but only after editing and re-saving a post. Weird?
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
I installed this and I didn't notice it work. Should this fix a 3.8 with just this plugin?