[wp-hackers] Problems with shortcode function in plugin

Ade Walker photofantaisie at gmail.com
Tue Dec 30 00:39:49 GMT 2008


Mike,

Thanks for the extra info. I'm now adapting this to fit my scenario and will
post back once I've got it working.

2008/12/29 Mike Schinkel <mikeschinkel at gmail.com>

> Ade Walker wrote:
> > So, I added the add_shortcode hook to my plugin file, and call the main
> plugin function within this hook.
>
> Would love to see a sample of the code once you get it working.
>
>
> Aaron D. Campbell wrote:
>
> > You can do something like this:
> >
> > function whatever($echo=false) {
> >   $output = '';
> >   foreach(){
> >       $output .= "something";
> >   }
> >   if ($echo)
> >       echo $output;
> >   return $output;
> > }
> >
>
> This is more of a PHP question, but given what I assume are negative
> performance implications of string concatenation in a loop for a large
> number of items, I've always used the following since I've come to PHP:
>
> function whatever($echo=false) {
>    $output = array();
>    foreach(){
>        $output[] = "something";
>    }
>    $output = implode('',$output);
>     if ($echo)
>        echo $output;
>    return $output;
> }
>
> Anyone else has thoughts on this?
>
> -Mike Schinkel
> http://mikeschinkel.com
> _______________________________________________
> 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