[wp-trac] Re: [WordPress Trac] #9227: in get_the_category_list(), filter categories before constructing list

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 25 02:04:19 GMT 2009


#9227: in get_the_category_list(), filter categories before constructing list
-------------------------+--------------------------------------------------
 Reporter:  KevinB       |       Owner:  anonymous                 
     Type:  enhancement  |      Status:  new                       
 Priority:  normal       |   Milestone:  Unassigned                
Component:  Template     |     Version:  2.7                       
 Severity:  normal       |    Keywords:  category, template, filter
-------------------------+--------------------------------------------------

Comment(by KevinB):

 Replying to [comment:2 filosofo]:
 > Replying to [ticket:9227 KevinB]:
 > > I had considered calling the new hook
 ''''get_the_category_for_list''''.  Instead I'm suggesting a more generic
 ''''get_the_category'''' hook, '''passing context''' as the second
 argument.  That would leave the API consistent for possible future use in
 filtering other contexts.
 >
 > So wouldn't it make more sense to add the filter to get_the_category()'s
 return?
 The problem I see is that get_the_category() does not know the context
 it's called in, whereas get_the_category_list() would always be a display
 context.  Since get_the_category() returns an array, some themes or
 plugins would not be unreasonable in using it in a raw/db context - for a
 maintenance operation which pertains to all stored post categories
 regardless of the currently logged user.  Is this a valid concern, or
 would you just assume that get_the_category() is always for display
 purposes and all backend operations use wp_get_object_terms()?

 I want to filter post categories in a display context for the current user
 (who may be restricted by my plugin), so I need a hook which will prevent
 me from fibbing to someone about the actual post categories.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9227#comment:3>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list