[wp-hackers] Returning instead of echoing

Ryan Boren ryan at boren.nu
Thu Nov 25 06:20:47 UTC 2004


On Thu, 2004-11-25 at 00:33 -0500, Owen Winkler wrote:
> Ryan Boren wrote:
> 
> >Has everyone digested this?  Unless someone hollers, I'll commit Owen's
> >patch.
> >  
> >
> The patch is fine but IMO incomplete, because all of the really useful 
> functionality (the information that most people would actually *want* to 
> get_ ) is tied up in wp_ functions that weren't converted as per the 
> agreed upon suggestions for changes.
> 
> I was hoping to see comment on that aspect, yet I can wait for 1.4 to 
> see it implemented.

Okay then.  As long as existing API is preserved, add new API and
refactor as needed.  However, let's target a few must haves at first,
rather than churning everything at once.  Let's flirt with it before we
marry it.

And let's try to establish some API rules.  Here are some suggestions.


get_the_*() - Template functions that do not echo their output.  These
are used for brief, one-line output, not lists.

the_*() - Template functions that echo their output.  They call
get_the_*().  The get_the_ and the_ prefixes are followed by a noun that
specifies an attribute of a WP post, comment, category, author, or other
object.  Filters are usually invoked on these attributes.

get_*() - Utility functions used by template functions to do the heavy
lifting.  These aren't usually called directly by templates but can be.
These typically involve more complex queries than the get_the_*() and
operate on more than just a single attribute.

get_*_link() - These functions return hrefs that point to WP queries or
other resources.  Higher level template functions will add the href to
an anchor.  The get_*_link() functions can be called directly by those
who want more control over the formatting of their anchors.

wp_*() - Template functions that produce complex output such as lists,
dropdowns, navigation controls, etc.


Ryan





More information about the hackers mailing list