Last active
June 29, 2019 06:36
-
-
Save joseconti/cac799f7dc873ef27d9f58366d93e206 to your computer and use it in GitHub Desktop.
Embed Gist Github WordPress
This file contains hidden or 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 | |
wp_embed_register_handler( 'gist', '/https?:\/\/gist\.github\.com\/([a-z0-9]+)\/([a-z0-9]+)?/i', 'joseconti_embed_gist' ); | |
function joseconti_embed_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