[wp-hackers] pre_get_posts problem

Dion Hulse (dd32) wordpress at dd32.id.au
Sat Jul 24 08:32:52 UTC 2010

On Sat, 24 Jul 2010 14:40:08 +1000, Mike Schinkel  
<mikeschinkel at newclarity.net> wrote:

> On Jul 23, 2010, at 8:32 AM, Dion Hulse (dd32) wrote:
>> For example, I've seen people suggesting using is_admin() inside  
>> certain filters to exclude the admin, where, in actual fact, they  
>> should be hooking somewhere completely different to prevent affecting  
>> other queries. Unless people highlight to others (and menu's have  
>> really helped do this) that doing things in certain ways will break  
>> code, people dont change, and new articles/blog posts dont get made  
>> explaining the "correct" new way of achieving it.
> Over the past several years and especially the past several months I've  
> done some pretty elaborate plugin development and to do so I've debugged  
> through code and found how to make things work.  However, I have  
> frequently felt like the methods I have discovered are difficult to make  
> robust and have felt that there have got to be a better ways.  
> Unfortunately I just haven't been able to find many (any?) authoritative  
> source(s) to help me identify what those ways should be, with a few  
> notable exceptions (Otto has some great blog posts on a few of these  
> topics.)  For many of those things I've found that absolutely nothing  
> (via Google searches) has been written on those specific topics.  While  
> I don't have to details suggestions for how to resolve this I do agree  
> that having a way to easily identify these best practices could be  
> really important to the plugin developer community as well as WordPress  
> at large.  JMTCW.

One of the problems I feel, is that those who understand some of these  
problems, are not the ones being asked to achieve the goal, And if they  
are, they don't realise that other people may need to do the same thing  
themselves.. At the same time, Comes times where you attempt something  
that no-one else has, and there simply isnt a filter for it.. Its going to  
happen sometimes

But with understanding comes blindness, I for example, would never even  
dream someone would use pre_get_posts to modify the front-end query, it  
screams of someone who doesnt have the foggiest of ideas on how the  
WordPress Query classes work; So its not something I would personally ever  
needed explaining, Unless it was asked of me, or i saw it being used  
incorrectly (And i often comment on a select few blogs I'm following for  
that reason, For example, This comment here:  
http://wpengineer.com/small-tips-using-wordpress-and-jquery/ - If anyone  
writes a blog with code excepts related to WordPress often, email me  
privately with the RSS feed and i'll post comments if I notice anything  

There is near nothing written on the Plugin/Theme upgraders for example,  
Ask me, and I can probably answer the query however; But I wouldn't know  
where to start writing for example, I wouldn't have a scenario which would  
require writing a howto on it.

Mark has recently put a form up for people to ask him questions, each week  
he's been giving a answer to a select few questions:  
http://markjaquith.wordpress.com/ask-wordpress/ &  
http://en.wordpress.com/tag/ask-wordpress/ for the previous answers. That  
sort of thing is a great start IMO, And I'll do the same one day when I  
have the time for it.

In the meantime, Developers shouldn't always trust code they find online,  
Sure, It says it achieves #1, but in actual fact, It does that whilst  
breaking #2, #3, and #4.. Always triple check what the codes hooking  
I know i shouldn't have to say that, but there are far too many  
Copy-Pasters in the WordPress community as a whole, Many may be able to do  
it themselves, but trust that 3rd party code was tested correctly, News  
for you, Often it isnt, and is written by a developer with less knowledge  
than you!

Dion Hulse / dd32

  e: contact at dd32.id.au
  Web: http://dd32.id.au/

More information about the wp-hackers mailing list