[wp-hackers] Re: $single

Owen Winkler ringmaster at midnightcircus.com
Thu Jun 17 13:44:18 UTC 2004


Why not use an array like $post_context[]?  It could contain sub-arrays
so the structure would look something like:

$post_context = array(
	'category' => array (
		'wordpress',
		'stupid ideas'
	),
	'month' => array (6)
);

This indicates a post context of categories "wordpress" and "stupid
ideas" during the month of June.  The post context would be easily set
once at the beginning of a Loop.

Using an array allows for easy future-proofing.  If you wanted to test
for/add a special context, you could do so without adjusting a class
definition or adding an explicit $on_* variable.

Plugins (especially those spoken of in the "Intervening in $posts"
thread) could test for, add, and remove contexts without confusing
possible code that tests for other contexts.  If you adjusted the
query's WHERE clause in your plugin, you could also add elements to the
post_context array that could be picked up by filters that run during
the_content display in the Loop.

Owen





More information about the hackers mailing list