[wp-hackers] Hook (Filter, Action) Documentation Idea

hakre hanskrentel at yahoo.de
Wed Sep 8 17:43:19 UTC 2010


----- Ursprüngliche Mail ----

> Von: Jeremy Clarke <jer at simianuprising.com>
> An: wp-hackers at lists.automattic.com
> Gesendet: Mittwoch, den 8. September 2010, 19:10:38 Uhr
> Betreff: Re: [wp-hackers] Hook (Filter, Action) Documentation Idea
> 
> This is a really cool idea. Even if the file wasn't run with include()  the
> functions would still get picked up by tools like PHPXref and NetBeans  which
> would give people in-tool documentation of the hooks.

yeah, I can imagine to type "wp_hook::" + [ctrl+space] ....  :)

> 
> Jacob is  right about it taking a long time to document all the filters, but
> they will  never be documented properly until there is a place in the code
> that is  missing the information, its inspiration for the OCD among us :)

Yes its work, I'm currently compiling a hook tracer with backtrace 
functionality. The good thing to use PHP as a definition of hooks is, that it's 
possible to verify stuff quite fast and to re-use existing tools. Little 
hook_tester that runs against an imagined wp-hooks.php file containing the 
(incomplete) hook definitions:

include('wp-hooks.php'); # load hooks definitions pseudo class
class hook_tester extends wp_hooks {
  ...
  public function __callStatic($name, $arguments) {
    if ( false === $this->hasMatch($name) ) # check for matching a VARY hookname
       throw new Exception(sprintf('Undefined Hook "%s"', $name));
  }
}


Testing is as easy as:

hook_tester::$name_your_hook();

Still this does not reduces the number of hooks so far, but it's possible to 
better test.

What does OCD stands for?

-- hakre





More information about the wp-hackers mailing list