Last active
July 10, 2018 06:59
-
-
Save schuhwerk/7201507 to your computer and use it in GitHub Desktop.
Add to wordpress theme's functions.php thanks to http://interconnectit.com/3920/embed-all-the-gists/ Usage:
Paste a gist link into a blog post or page and it will be embedded eg:
https://gist.github.com/2926827
If a gist has multiple files you can select one using a url in the following format:
https://gist.github.com/2926827?file=embed-gist.php …
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
wp_embed_register_handler( 'gist', '/https?:\/\/gist\.github\.com(\/[^\/]+)?\/([a-z0-9]+)(\?file=.*)?/i', 'wp_embed_handler_gist' ); | |
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) { | |
$embed = sprintf( | |
'<script src="https://gist.github.com/%1$s.js%2$s"></script>', | |
esc_attr($matches[2]), | |
esc_attr($matches[3]) | |
); | |
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