Last active
October 17, 2015 16:40
-
-
Save levantoan/fae35ed5bf667d968a68 to your computer and use it in GitHub Desktop.
Add gist to wordpress. single and multi file
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
<?php | |
//add shortoce gist to wordpress | |
//Use [gist id="" file=""] | |
/* | |
EX: https://gist.github.com/fae35ed5bf667d968a68#file-shortcode-gist-php | |
=> shortcode: [gist id="fae35ed5bf667d968a68" file="ShortCode-Gist.php"] | |
*/ | |
function gist_func( $atts ){ | |
$atts = shortcode_atts( array( | |
'id' => '', | |
'file' => '' | |
), $atts, 'gist' ); | |
if($atts['id']){ | |
$file = ($atts["file"]) ? '?file='.$atts["file"] : ''; | |
return '<script src="https://gist.github.com/'.$atts['id'].'.js'.$file.'"></script>'; | |
}else{ | |
return false; | |
} | |
} | |
add_shortcode('gist','gist_func'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment