Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Last active December 12, 2015 03:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kopepasah/4705122 to your computer and use it in GitHub Desktop.
Save kopepasah/4705122 to your computer and use it in GitHub Desktop.
This gist shortcode with get the file content of each gist and output the contents for you site.
<?php
function gist_shortcode( $atts ) {
extract( shortcode_atts( array(
'user' => '',
'id' => '',
'file' => '',
), $atts ) );
if ( empty( $user ) | empty( $id ) | empty( $file ) )
return;
$output = file_get_contents( 'https://gist.github.com/' . $user . '/' . $id . '/raw/' . $file );
return $output;
}
add_shortcode( 'gist', 'gist_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment