[wp-hackers] Returning instead of echoing

Ryan Boren ryan at boren.nu
Thu Nov 11 20:07:46 UTC 2004


On Thu, 2004-11-11 at 09:40 -0500, Owen Winkler wrote:
> the_* Conversion Guide
> rev.#1 - Please amend/comment
> 
> In the interests of facilitating the use of template tags for the novice 
> user, and leaving a rich API open for developers, the functions that 
> produce output in a template should be renamed following these rules:
> 
> * Any output-producing function beginning with "the_" should have a 
> corresponding "get_the_" function that accepts the same arguments and 
> returns its value rather than echoing.

Yes.

> * Functions that don't begin with "the_" yet produce output in 
> index.php, header.php, footer.php, or sidebar.php need to be converted 
> to the "the_"/"get_the_" style also, while leaving their original 
> version for future deprication.

Hold off on this until after 1.3.

> * Filters that are applied to output should be applied in the "get_the_" 
> function and not the "the_" function.  The "the_" function should simply 
> echo the "get_the_" function's output.  Existing function pairs that 
> don't follow this structure need to be changed.

Yes.

> Questions::
> Should all get_ functions be converted to parse_str argument format?
>
> What do you think of this:
> if(!is_array($a))parse_str($a);extract($a);

That would work, but, again, I think we should wait until after 1.3 to
convert old functions.  For new get_* functions, we need to go ahead and
set a policy for parse_str().  Do we always use it?  Do we use it only
for functions with argument lists beyond a certain size?

> Should all get_ functions have any echo functionality removed?

I say leave existing functions as is for now.

For 1.3, let's focus on points 1 and 3 from your list.  We need to
finish off this development cycle and get into beta.  Even though the
changes are fairly straightforward, this is still quite a bit of API
churn.

Thoughts?

Ryan




More information about the hackers mailing list