Created
May 27, 2018 07:47
-
-
Save SanjeevMohindra/8f02b92dde85e0fc22eaefdb18ec8c16 to your computer and use it in GitHub Desktop.
Convert shortcode to AMP compatible Shortcode
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 | |
// Do not copy the above php tag in your function.php | |
/** | |
* Change shortcodes to AMP compatible Shortcodes | |
* | |
* Add this to your function.php | |
* | |
* @author MetaBlogue | |
* @license GPL-2.0+ | |
* @link https://metablogue.com/configure-enable-amp-wordpress/ | |
*/ | |
add_shortcode('gist-amp', 'jetpack_gist_amp_conversion'); | |
function jetpack_gist_amp_conversion( $atts, $content = NULL ) { | |
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { | |
$amp_gist_string = '<amp-gist layout="fixed-height" height="225" data-gistid="' .$content. '">' . '</amp-gist><br />'; | |
return $amp_gist_string; | |
} else { | |
return do_shortcode('[gist]' .$content .'[/gist]'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment