-
-
Save iqbalrony/5ee9d5b31a20ea262d42f7137a6b7ac6 to your computer and use it in GitHub Desktop.
Call a shortcode function by tag name
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 | |
/** | |
* Call a shortcode function by tag name. | |
* | |
* @param string $tag The shortcode whose function to call. | |
* @param array $atts The attributes to pass to the shortcode function. Optional. | |
* @param array $content The shortcode's content. Default is null (none). | |
* | |
* @return string|bool False on failure, the result of the shortcode on success. | |
*/ | |
function do_shortcode_callback( $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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment