[wp-hackers] 2.4 idea: query/display logic split in admin tools

Stephane Daury wordpress at tekartist.org
Mon Nov 19 14:30:10 GMT 2007


On Nov 18, 2007, at 0:34, Jacob wrote:

> Stephane Daury wrote:
>>
>> Working on WPhone, I often wished that the query and display logics  
>> were separated, or the recordset returned, in some of the admin  
>> listing tools.
>>
>> [snip]

> [snip]

> It would probably be difficult, since you would have to have two (or  
> more) classes or two or more functions where one was used  
> previously. You would also have to keep the original function  
> behavior as it was and build a companion for what you are proposing.  
> In this way, you can have single functionality separate of both  
> functions but used in both. If that makes any sense.

Actually, it could be a lot less involved than this, if nothing else  
in the spirit of making it happen easily/fast, though some could argue  
about increased memory requirements.

EG:
- in /wp-admin/includes/templates.php
cat_rows() echos $output (based on looping on $categories, from  
get_categories()), or returns false.
Returning $categories after the print, on success, would be enough,  
when coupled with the following.

- in /wp-admin/categories.php
Instead of just calling cat_rows(), all we'd have to do is add  
$our_var = cat_rows().
Then the print happens, and anyone wanting to extend the functionality  
could access $our_var.
Of course, doing it this way would mean one could only use $our_var  
after the listing is echoed, but it'd already be more flexible than  
now, and the same logic seems to be viable for all of the *_rows  
convenience functions I've seen in the admin.

Stephane








More information about the wp-hackers mailing list