Created
March 25, 2014 17:49
-
-
Save dobsondev/9767289 to your computer and use it in GitHub Desktop.
Shortcode for Embedding GitHub Gist's - Used in DobsonDev Shortcodes Plugin for WordPress
This file contains hidden or 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 | |
/* Adds a shortcode for displaying GitHub Gists */ | |
function dobson_create_github_gist($atts) { | |
extract(shortcode_atts(array( | |
'source' => "Invalid Source", | |
), $atts)); | |
$source_headers = @get_headers($source); | |
if (strpos($source_headers[0], '404 Not Found')) { | |
return '<p> Invalid GitHub Gist source. Please check your source. </p>'; | |
} else { | |
return '<script src="' . $source . '.js"></script>'; | |
} | |
} | |
add_shortcode('embedGist', 'dobson_create_github_gist'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment