[wp-testers] post-format 'standard'?
Dougal Campbell
dougal at gunters.org
Tue Jan 4 18:43:54 UTC 2011
On Jan 4 2011 1:23 PM, Andrew Nacin wrote:
> On Tue, Jan 4, 2011 at 1:12 PM, Dougal Campbell<dougal at gunters.org> wrote:
>
>> So, why doesn't get_post_format() return 'standard' for regular posts?
>>
>> It returns an empty string, and as a result, we have special-case handlers
>> sprinkled throughout the rest of the code to handle converting the empty
>> result to the string 'standard'. Is there a reason for this that I'm
>> overlooking?
>>
>> (this is in response to Chip Bennett's query about it on Twitter and on my
>> blog)
>
> We don't store the standard post format in the database. Having a "standard"
> format is no different from having no format. Thus has_post_format() returns
> false, and get_post_format() returns empty -- it's by design.
>
> Nacin
Okay, I understand not storing in the db -- it's a default case, we
don't need/want the clutter in the terms mapping. So on *save*
operations, it makes sense to strip out 'standard', if it's been passed in.
But for reading post information, why not move the special casing into
get_post_format(), instead of duplicating it?
get_post_format(), get_post_format_string(), get_post_class(),
wp_xmlrpc_server::mw_getPost(), and
wp_xmlrpc_server::mw_getRecentPosts() all have special case 'if'
clauses, all immediately after calling get_post_format(). (I only
checked wp-includes, there might be more cases in the wp-admin code).
Seems it would make more sense to let get_post_format() return
'standard', and eliminate a lot of checking in other parts of core. It
would also help future-proof against future code changes that might miss
the exception.
Again, I'll admit that I might be overlooking something, and the change
might complicate something elsewhere in the code.
--
Dougal Campbell <dougal at gunters.org>
http://dougal.gunters.org/
http://twitter.com/dougal
http://twitual.com/
More information about the wp-testers
mailing list