Skip to content

Instantly share code, notes, and snippets.

@cgrymala
Created July 21, 2015 16:39
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 cgrymala/5674bfaf6b98010a2b68 to your computer and use it in GitHub Desktop.
Save cgrymala/5674bfaf6b98010a2b68 to your computer and use it in GitHub Desktop.
Removes the [youtube] and [vimeo] shortcodes from JetPack Shortcode Embeds module
<?php
/**
* Filter the list of JetPack shortcodes to remove the YouTube and
* Vimeo shortcodes from the list
* @param array $shortcodes a numerically-indexed array of the absolute
* paths to the shortcode definition files
* @return array the filtered array
*/
function jetpack_allow_native_youtube_vimeo_oembeds( $shortcodes ) {
$good_shortcodes = array();
foreach ( $shortcodes as $s ) {
/**
* The shortcodes array is a numerically-indexed array of the full,
* absolute paths to the shortcode files. For instance, the
* YouTube shortcode array item would look something like:
* /home/youruser/public_html/wp-content/plugins/jetpack/modules/shortcodes/youtube.php
* Therefore, we have to search for the appropriate strings within the array items
*/
if ( stristr( $s, 'youtube' ) || stristr( $s, 'vimeo' ) )
continue;
/**
* If this shortcode isn't Vimeo or YouTube, allow it
*/
$good_shortcodes[] = $s;
}
/**
* Return the modified list of available shortcodes
*/
return $good_shortcodes;
}
add_filter( 'jetpack_shortcodes_to_include', 'jetpack_allow_native_youtube_vimeo_oembeds' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment