It is easier to read: When is what called? If you are debugging a hook you can immediately see if you have to read the function or not: If it is not your hook, you can skip the code.
In my themes and plugins I combine all registrations for actions, filters and shortcodes at the top and I add the hook to the PHPDoc block:
1 2 3 4 5 6 7 8 9 10 11 12 13 | add_action( 'wp_head', 'foo' ); add_action( 'shutdown', 'bar' ); /** * Foo you! * * @wp-hook wp_head * @return void */ function foo() { print '<!-- foo -->'; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.