[wp-hackers] Is there a way to get the callback function name out of a shortcode _programmatically_?

Nikola Nikolov nikolov.tmw at gmail.com
Wed Nov 13 06:53:01 UTC 2013


Hm... I wonder if the code I wrote doesn't work. Can you try to get the
callback for gallery? And see if that works.


On Wed, Nov 13, 2013 at 1:37 AM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> Sorry guys to bother you back on this.... In a slightly more complicated
> case ( a visual composer shortcode ) where the shortcode data is stored in
> an object in the $shortcode_tags array, I'm hitting a brick wall.
>
> The shortcode I'm after is "vc_wp_posts" and I use this one liner to
> ATTEMPT to get it   $callback = get_shortcode_callback("vc_wp_posts");
>
> using the function we had yesterday.
>
> function get_shortcode_callback( $shortcode ) {
>     return isset( $GLOBALS['shortcode_tags'][ $shortcode ] ) ?
> $GLOBALS['shortcode_tags'][ $shortcode ] : false;
> }
>
> and it comes back with a FALSE.
>
> I know why but I don't know how to get to piece I need to...
>
> Here is the $shortcode_tags var dump view
>
> shortened for brewity
>
> array (size=74)
>   'embed' => string '__return_false' (length=14)
>   'wp_caption' => string 'img_caption_shortcode' (length=21)
>   'caption' => string 'img_caption_shortcode' (length=21)
>   'gallery' => string 'gallery_shortcode' (length=17)
>   'audio' => string 'wp_audio_shortcode' (length=18)
>   'video' => string 'wp_video_shortcode' (length=18)
>   'vc_column_inner' =>
>     array (size=2)
>       0 =>
>         object(WPBakeryShortCode_VC_Column_Inner)[173]
>           protected 'predefined_atts' =>
>             array (size=3)
>               ...
>           protected 'shortcode' => string 'vc_column_inner' (length=15)
>           protected 'html_template' => null
>           protected 'atts' => null
>           protected 'settings' =>
>             array (size=11)
>               ...
>           protected 'is_plugin' => boolean true
>           protected 'is_theme' => boolean false
>       1 => string 'output' (length=6)
>   'vc_row' =>
>     array (size=2)
>       0 =>
>         object(WPBakeryShortCode_VC_Row)[174]
>
> etc...
>
> now I am gonna fast forward to the section that deals with the shortcode
> I'm after...
>
> and here it is...
>
> 'vc_wp_posts' =>
>     array (size=2)
>       0 =>
>         object(WPBakeryShortCode_VC_Wp_Posts)[118]
>           protected 'shortcode' => string 'vc_wp_posts' (length=11)
>  <------------ this is where the information we are after.
>           protected 'html_template' => null
>           protected 'atts' => null
>           protected 'settings' =>
>             array (size=6)
>               ...
>           protected 'is_plugin' => boolean true
>           protected 'is_theme' => boolean false
>       1 => string 'output' (length=6)
>
>   'vc_wp_links' =>
>     array (size=2)
>       0 =>
>
>
>
>
>
>
>
>
>
>
>
>
> On Tue, Nov 12, 2013 at 5:28 AM, J.D. Grimes <jdg at codesymphony.co> wrote:
>
> > Yeah, I thought it would reduce bootstrap. Using do_shortcode() is so
> easy
> > for new devs to do, if we want them to use the better alternative, I
> think
> > it would be adopted quicker in a wrapper like this.
> >
> > On Nov 11, 2013, at 10:02 PM, Ryan McCue <lists at rotorised.com> wrote:
> >
> > > J.D. Grimes wrote:
> > >> Here is a function that does just that:
> > >
> > > This seems like something we should bring in to core to avoid everyone
> > > using `do_shortcode` and running the full regex parser every time.
> > >
> > > I see you proposed http://core.trac.wordpress.org/ticket/25435 but it
> > > got wontfix'd. Anyone else think we should reopen?
> > >
> > > --
> > > Ryan McCue
> > > <http://ryanmccue.info/>
> > > _______________________________________________
> > > 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
> >
> _______________________________________________
> 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