Created
February 22, 2012 21:01
-
-
Save r-a-y/1887242 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. | |
*/ | |
function shortcode_exists( $shortcode = false ) { | |
global $shortcode_tags; | |
if ( ! $shortcode ) | |
return false; | |
if ( array_key_exists( $shortcode, $shortcode_tags ) ) | |
return true; | |
return false; | |
} | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excellent! Just what I was looking for.