-
-
Save sheabunge/2916977 to your computer and use it in GitHub Desktop.
Check if a shortcode exists in WordPress
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 | |
if ( ! function_exists( 'shortcode_exists' ) ) : | |
/** | |
* Check if a shortcode is registered in WordPress. | |
* | |
* Examples: shortcode_exists( 'caption' ) - will return true. | |
* shortcode_exists( 'blah' ) - will return false. | |
* | |
* @param string $shortcode The name of the shortcode to check | |
* @return bool Whether the shortcode exists or not | |
*/ | |
function shortcode_exists( $shortcode ) { | |
global $shortcode_tags; | |
return array_key_exists( $shortcode, $shortcode_tags ) ); | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment