Skip to content

Instantly share code, notes, and snippets.

@ccbikai
Last active May 13, 2017 15:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ccbikai/11216526 to your computer and use it in GitHub Desktop.
Save ccbikai/11216526 to your computer and use it in GitHub Desktop.
Wordpress 嵌入 Gist代码
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