Skip to content

Instantly share code, notes, and snippets.

@aldolat
Created April 17, 2017 18:07
Show Gist options
  • Save aldolat/4ad8ee34766fb89bdb4b436ff0983226 to your computer and use it in GitHub Desktop.
Save aldolat/4ad8ee34766fb89bdb4b436ff0983226 to your computer and use it in GitHub Desktop.
Embed a Gist in WordPress using a shortcode.
<?php
/**
* Create the shortcode to embed a Gist.
*
* @example [gist]https://gist.github.com/aldolat/8625342[/gist]
* @since 4.5
*/
function aldolat_gist_embed( $atts, $content = null ) {
extract( shortcode_atts( array(), $atts ) );
$output = '<script src="' . esc_url( $content, 'https' ) . '.js"></script>';
return $output;
}
add_shortcode( 'gist', 'aldolat_gist_embed' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment