Another one in the series of “… hates developers” is WordPress. I’ve been messing with it since I installed 2.0 to power this blog. I’m not happy.
As the title already states I’m not saying that WordPress is bad for the common visitor or even the common user/author. Yes, it has some problems but they don’t even come close to what it has to offer to the power user. If you’re trying to create a plugin that does something they didn’t expect you’re out of luck. That, or the documentation sucks as hell.
To elaborate I’d like to share a bit of it’s code from template-functions-general.php:
function get_post_time( $d = 'U', $gmt = false ) {
global $post;
if ( $gmt )
$time = $post->post_date_gmt;
else
$time = $post->post_date;
$time = mysql2date($d, $time);
return apply_filters('get_the_time', $time, $d, $gmt);
}
As you can see getting a time when you’re not in the main post loop (that sets the global $post) is a bit weird. You have to set a global variable post and then run this thing. You should probably know that this is not the method that is usually called from the templates – that’s the_time that calls get_the_time with a filter, get_the_time retrieves the time_format setting and it calls get_post_time.
Another great thing is getting an author of the post. I gave up end wrote my own sql statement. I don’t like it and if there’s another way please tell me – template-functions-author.php doesn’t tell me anything useful. The global object $authordata is just too much.
I understand that this kind of code gets into version 1. I can’t understand how it gets into version 2, especially when they said they improved abstraction in this version. OK, I can understand the focus – first the users, then the writers, hopefully now the developers. So my proposition for version 3 is a complete rewrite of the backend to something more API-ish so we (plugins and the core) can use the same built-in API for most of the stuff.