Skip to content

Instantly share code, notes, and snippets.

@websupporter
Last active March 16, 2016 11:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save websupporter/ccfc45681e7c5ad7800f to your computer and use it in GitHub Desktop.
<?php
/**
* If you have already included Gist as a handler, you could
* use this Snippet to include the raw output as iframe...
* ... if... well if github would permit it... but
* just for demonstration purposes.
* **/
add_filter( 'embed_handler_html', 'fwe_embed_handler_html', 10, 4 );
function fwe_embed_handler_html( $html, $url, $attr, $post_ID = null ){
if( ! preg_match( '/https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/i', $url, $matches ) )
return $html;
return '<iframe src="https://gist.githubusercontent.com/' . $matches[1] . '/' . $matches[2] . '/raw/"></iframe>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment