Skip to content

Instantly share code, notes, and snippets.

@ivankristianto
Created September 22, 2013 01:57
Show Gist options
  • Save ivankristianto/6655970 to your computer and use it in GitHub Desktop.
Save ivankristianto/6655970 to your computer and use it in GitHub Desktop.
This snippet code is to show gist snippet into the WordPress content with just pasting the URL into post content
wp_embed_register_handler( 'gist', '#https://gist\.github\.com/(.+?)/(.+?)($|&)#i', 'wp_embed_handler_gist' );
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s/%2$s.js"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);
return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment