/**
* Call a shortcode function by its tag name.
*
* Directly executes a shortcode's callback function using the shortcode's
* tag name. Can execute a function even if it's in an object class.
* Simply pass the shortcode's tag and an array of any attributes.
*
* @global array $shortcode_tags
* @param string $tag The shortcode tag name.
* @param array $atts The attributes (optional).
* @param array $content The shortcode content (null by default).
*
* @return string|bool False on failure, the result of the shortcode on success.
*/
function do_shortcode_func( $tag, array $atts = array(), $content = null ) {
global $shortcode_tags;
if ( ! isset( $shortcode_tags[ $tag ] ) ) {
return false;
}
return call_user_func( $shortcode_tags[ $tag ], $atts, $content, $tag );
}
Call a shortcode function by tag name
This post brought to you by RocketGeek, ButlerBlog, and the following: