Skip to content

Instantly share code, notes, and snippets.

@corenominal
Last active August 23, 2016 10:16
Show Gist options
  • Save corenominal/cfd8b2315a4c0302f297 to your computer and use it in GitHub Desktop.
Save corenominal/cfd8b2315a4c0302f297 to your computer and use it in GitHub Desktop.
A simple WordPress shortcode for embedding a GitHub Gist
<?php
/**
* Github Gists
* Usage: [gist url="https://gist.github.com/corenominal/0efedf14eca28453a58e"]
*/
function corenominal_shortcode_gist( $atts, $content = null)
{
$atts = shortcode_atts(
array(
'url' => 'https://gist.github.com/corenominal/0efedf14eca28453a58e'
), $atts
);
return '<script src="' . $atts['url'] . '.js"></script>';
}
add_shortcode( 'gist', 'corenominal_shortcode_gist' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment