Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Very simple shortcode to easily add gists in WordPress using the url for reference. All it does is wrap the specified url with the script tags needed.
<?php
// [gist url="https://gist.github.com/Ugotsta/49d45a54022f00060f71"]
function gist_function( $atts ) {
$a = shortcode_atts( array(
'url' => 'https://gist.github.com/Ugotsta/49d45a54022f00060f71'
), $atts );
return '<script src="' . esc_attr($a['url']) . '.js"></script>';
}
add_shortcode( 'gist', 'gist_function' );
?>
@bappi-d-great
Copy link

bappi-d-great commented Jul 30, 2014

Cool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment