-
-
Save chasereeves/3812595 to your computer and use it in GitHub Desktop.
embed gist shortcode
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
function gist_shortcode($atts, $content = NULL) { | |
extract( shortcode_atts( array( | |
'id' => '', | |
'title' => '' | |
), $atts ) ); | |
if (empty ($id) ) | |
return; | |
$gist = '<div class="github-gist-block">'; | |
if(!empty($title)) | |
$gist .= '<h4>'.$title.'</h4>'; | |
$gist .= '<script src="https://gist.github.com/'.$id.'.js"></script>'; | |
$gist .= '</div>'; | |
// now send it all back | |
return $gist; | |
} | |
add_shortcode ( 'gist', 'gist_shortcode'); | |
/* USAGE | |
the ID is found in the URL of the gist. For example, this one is https://gist.github.com/gists/3812565/ | |
[gist id="3812565"] | |
You can add an optional title to show up above the block | |
[gist id="3812565" title="My Gist Title"] | |
without the ID present, nothing will fire. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment