Skip to content

Instantly share code, notes, and snippets.

@tomjn
Forked from r-a-y/shortcode.php
Last active December 16, 2015 09:09
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 tomjn/5411408 to your computer and use it in GitHub Desktop.
Save tomjn/5411408 to your computer and use it in GitHub Desktop.
Always ommit trailing php close tags, indent correctly, and remove the IDE unfriendly shorthand
<?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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment