Skip to content

Instantly share code, notes, and snippets.

@SenpaiSilver
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SenpaiSilver/0f775a6dac4807c4e97a to your computer and use it in GitHub Desktop.
Save SenpaiSilver/0f775a6dac4807c4e97a to your computer and use it in GitHub Desktop.
<?php
/*
** Please get this plugin from the repo:
** https://github.com/SenpaiSilver/ShowMeYourGists
**
** This paste isn't always up to date.
*/
function embedGistsInPosts($post) {
$pat = '/<p>(https?:)\/\/gist.github.com\/(.*)\/(.*)<\/p>/mi';
$sub = '<script src="$1//gist.github.com/$2/$3.js"></script>';
$post = preg_replace($pat, $sub, $post);
return ($post);
}
add_action('the_content', 'embedGistsInPosts');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment