Created
July 21, 2015 16:39
-
-
Save cgrymala/5674bfaf6b98010a2b68 to your computer and use it in GitHub Desktop.
Removes the [youtube] and [vimeo] shortcodes from JetPack Shortcode Embeds 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 | |
/** | |
* 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