[wp-hackers] Settings Page-only Shortcodes

Viper007Bond viper at viper007bond.com
Mon Aug 11 01:06:34 GMT 2008


No, there isn't, but I've had a patch open for a while to do that:
http://trac.wordpress.org/ticket/6606

You'll need to write wrapper functions if you want the shortcode all
processed by one function (this is forward compatible with my patch):


add_shortcode( 'foo', 'shortcode_foo' );
add_shortcode( 'bar', 'shortcode_bar' );

function shortcode_foo( $atts, $content = NULL ) {
    return myshortcode( $atts, $content, 'foo' );
}

function shortcode_bar( $atts, $content = NULL ) {
    return myshortcode( $atts, $content, 'bar' );
}

function myshortcode( $atts, $content, $tag ) {

    /* Do Stuff */

    return $something;
}

On Sun, Aug 10, 2008 at 12:19 PM, Matt <speedboxer at gmail.com> wrote:

> How can I point them at the same function if the don't return the name
> of the shortcode to it (or, at least, not that I can tell)?
>
> On Sun, Aug 10, 2008 at 2:36 AM, Viper007Bond <viper at viper007bond.com>
> wrote:
> > Why is it wasteful? And what alternative is there other than pointing
> them
> > all at the same function?
> >
> > On Sat, Aug 9, 2008 at 11:24 PM, Matt <speedboxer at gmail.com> wrote:
> >
> >> Right, thanks.
> >>
> >> I have another question though. What would be the best way of
> >> processing a lot of shortcodes? Making a function for each seems
> >> wasteful (these shortcodes don't have any attributes and are all
> >> self-closing).
> >>
> >> On Sat, Aug 9, 2008 at 7:44 PM, Viper007Bond <viper at viper007bond.com>
> >> wrote:
> >> > No as they were designed for posts.
> >> >
> >> > On Sat, Aug 9, 2008 at 6:12 PM, Matt <speedboxer at gmail.com> wrote:
> >> >
> >> >> On Sat, Aug 9, 2008 at 5:52 PM, Viper007Bond <viper at viper007bond.com
> >
> >> >> wrote:
> >> >> > Then just register them conditionally.
> >> >>
> >> >> Alright, thought there might be some built-in functionality to do it.
> >> >> Thanks.
> >> >>
> >> >> --
> >> >> Matt (http://mattsblog.ca/)
> >> >> _______________________________________________
> >> >> wp-hackers mailing list
> >> >> wp-hackers at lists.automattic.com
> >> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Viper007Bond | http://www.viper007bond.com/ |
> http://www.finalgear.com/
> >> > _______________________________________________
> >> > wp-hackers mailing list
> >> > wp-hackers at lists.automattic.com
> >> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> >
> >>
> >>
> >>
> >> --
> >> Matt (http://mattsblog.ca/)
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> >
> >
> >
> > --
> > Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
> Matt (http://mattsblog.ca/)
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/


More information about the wp-hackers mailing list