post-page

10 Useful WordPress Hook Hacks

2
responses
by
 
on
August 18th, 2009
in
brainstorming, WordPress Hack, WordPress Plugins
heading
heading
heading
2
Responses

 

Comments

  1. Otto (215 comments.) says:

    Their explanation of hooks is a bit off. Right at the beginning they get it wrong, here:

    In this example, we hook our own custom function to WordPress’ publish-post function, which means that every time WordPress executes the publish-post function, it will also execute this hooked function.

    That’s not entirely accurate. The hooked function gets executed not when the publish post function is called, but when the code in WordPress does do_action(‘publish_post’). The hook names do not have to match the functions, and not all functions can be hooked. Same goes for filters, you’re not filtering functions, you’re filtering whatever is passed into apply_filters().

    This is an important distinction to make, because I often see new plugin programmers trying to hook to function names and then wondering why it doesn’t work.

    Other thoughts:

    – The example given for number 2 is incredibly brilliant. I can’t believe I didn’t think of it. However, consider caching, wp-super-cache would break this sort of thing.

    – Number 8 only gets the body and part of the head, not the whole page. Putting a hook exactly where you need it is much more useful, but if you really want the whole page, no hooks are really needed. Just ob_start(“callback”) in your plugin. You don’t even need the flush, that happens automatically at end of execution. This may make your page seem slower though.



Trackbacks/Pingbacks

  1. […] Digest for August 21st Home > Lifestream > Daily Digest for August 21st Shared 10 Useful WordPress Hook Hacks « Weblog Tools Collection RT ??yagg.kr? ??? ?? ?? ?????. ??? ??? ?????.^^ […]

Obviously Powered by WordPress. © 2003-2013

page counter
css.php