Created
September 4, 2015 15:24
-
-
Save nguyenvanduocit/aadc8320e376ac64be35 to your computer and use it in GitHub Desktop.
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: WP Gist oEmbed | |
Plugin URI: https://laptrinh.senviet.org | |
Description: Embed source from gist.github. | |
Author: nguyenvanduocit | |
Version: 1.9.0 | |
Author URI: http://nvduoc.senviet.org | |
*/ | |
class sv_gist_oembed { | |
private $regex = "/https:\\/\\/gist\\.github\\.com\\/([a-zA-Z0-9]*)\\/([a-z0-9]*)$/i"; | |
function __construct() | |
{ | |
wp_embed_register_handler( | |
'sv-gist-oembed', | |
$this->regex, | |
array( $this, 'handler' ) | |
); | |
} | |
public function handler( $matches, $attr, $url, $rawattr ) | |
{ | |
return sprintf('<script src="https://gist.github.com/%1$s/%2$s.js"></script>', $matches[1], $matches[2]); | |
} | |
} | |
new sv_gist_oembed(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment