Created
April 17, 2017 18:07
-
-
Save aldolat/4ad8ee34766fb89bdb4b436ff0983226 to your computer and use it in GitHub Desktop.
Embed a Gist in WordPress using a shortcode.
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 | |
/** | |
* Create the shortcode to embed a Gist. | |
* | |
* @example [gist]https://gist.github.com/aldolat/8625342[/gist] | |
* @since 4.5 | |
*/ | |
function aldolat_gist_embed( $atts, $content = null ) { | |
extract( shortcode_atts( array(), $atts ) ); | |
$output = '<script src="' . esc_url( $content, 'https' ) . '.js"></script>'; | |
return $output; | |
} | |
add_shortcode( 'gist', 'aldolat_gist_embed' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment