Skip to content

Instantly share code, notes, and snippets.

@r-a-y
Created February 22, 2012 21:01
Show Gist options
  • Save r-a-y/1887242 to your computer and use it in GitHub Desktop.
Save r-a-y/1887242 to your computer and use it in GitHub Desktop.
Check if a shortcode exists in WordPress
<?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;
?>
@Vitzkrieg
Copy link

Excellent! Just what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment