[wp-hackers] Is there a way to get the callback function name out of a shortcode _programmatically_?
Haluk Karamete
halukkaramete at gmail.com
Mon Nov 11 20:26:35 UTC 2013
Thank you guys...
Nikola, i'm just curious. I'm not sure as to why I should worry about the
"is_callable" matter? Why would an existing shortcode tag work with a not
callable function... see what I mean?
On Mon, Nov 11, 2013 at 12:21 PM, Nikola Nikolov <nikolov.tmw at gmail.com>wrote:
> You can access the global $shortcode_tags variable. If you want to wrap it
> in a function, it would look something like this:
>
> function get_shortcode_callback_for( $shortcode ) {
> return isset( $GLOBALS['shortcode_tags'][ $shortcode ] ) ?
> $GLOBALS['shortcode_tags'][ $shortcode ] : false;
> }
>
> This will return the callback for the shortcode tag that you passed, or
> false if such shortcode hasn't been registered yet.
>
> Note, that the returned callback can be any type of
> callable<http://php.net/manual/en/language.types.callable.php>,
> So - you should use is_callable( $callback )<
> http://us3.php.net/is_callable> in
> order to check if the parameter is actually callable.
>
>
> On Mon, Nov 11, 2013 at 10:12 PM, Haluk Karamete <halukkaramete at gmail.com
> >wrote:
>
> > Is there a way to get the callback function name out of a shortcode
> > _programmatically_?
> >
> > for example
> >
> > get_shortcode_callback_for('caption')
> >
> > would return
> >
> > "img_caption_shortcode"
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list