Created
July 20, 2020 19:06
-
-
Save joemcgill/765c9ed02185c11f7c957bd3ef8bd0ae to your computer and use it in GitHub Desktop.
Fix Instagram embeds with Jetpack shortcodes module
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 | |
// Disable Jetpack's instagram shortcode since it breaks oEmbed functionality. | |
add_filter( 'jetpack_shortcodes_to_include', function ( $shortcodes ) { | |
unset( $shortcodes['instagram'] ); | |
return $shortcodes; | |
}, 99 ); | |
// Add a simple shortcode wrapper for the embed functionality to support the shortcode format. | |
add_shortcode( 'instagram', function ( $atts ) { | |
global $wp_embed; | |
if ( empty( $atts['url'] ) ) { | |
return ''; | |
} | |
return $wp_embed->shortcode( $atts, $atts['url'] ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a quick workaround for this Jetpack bug which breaks the Instagram block in WordPress. Automattic/jetpack#9331