Last active
May 13, 2017 15:54
-
-
Save ccbikai/11216526 to your computer and use it in GitHub Desktop.
Wordpress 嵌入 Gist代码
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
function wp_iframe_handler_gist( $matches, $attr, $url, $rawattr ) { | |
$iframe = '<iframe width="100%" height="300" src="https://gist.github.com/'. esc_attr($matches[1]) .'/'. esc_attr($matches[2]) . '.pibb" frameborder=0 ></iframe>'; | |
return apply_filters( 'iframe_gist', $iframe, $matches, $attr, $url, $rawattr ); | |
} | |
wp_embed_register_handler( 'gist_iframe', '#https://gist.github.com/(.*?)/([\w]+)#i', 'wp_iframe_handler_gist' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/(.*?)/([\d]+)#i 需改成 #https://gist.github.com/(.*?)/([\w]+)#i
因为原链接是: https://gist.github.com/ccbikai/11216526
现在是:https://gist.github.com/lmm214/5db1a1702a880baecba5