[theme-reviewers] Use of Action/Filter Hooks in WordPress Theme

Chip Bennett chip at chipbennett.net
Tue Jul 26 14:14:47 UTC 2011


Personally, I think action/filter hooks are Teh Awesome. I also use them,
quite extensively<https://github.com/chipbennett/oenology/blob/master/functions/hooks.php>
.

But I'm not really sure what you're asking?

Are they acceptable? Of course; provided they are implemented properly, per
the appropriate API conventions.

Are they best practice? In my personal opinion, they are; I prefer them to,
e.g. pluggable functions. But at least currently, the Guidelines are silent
on custom hooks.

(p.s. you should prefix your hooks with theme_slug, or at the very least,
make sure your hook-name prefixes are consistent with the rest of the Theme
- which, IIRC, is Chip Life, or "chip_life" as a prefix?)

Chip

On Tue, Jul 26, 2011 at 8:08 AM, Qamar Ashraf <life.object at gmail.com> wrote:

> Hello,
>
> I am going to share my WordPress Theme development logic for an expert
> opinion. So it will help me and others in the WP theme development, Here is
> a sample code of header template,
>
>  <?php do_action( 'chip_header_pre' ); ?>
>>   <div id="header">
>>     <div id="header-data">
>>       <?php do_action( 'chip_header' ); ?>
>>     </div> <!-- end #header-data -->
>>   </div> <!-- end #header -->
>> <?php do_action( 'chip_header_post' ); ?>
>
>
>
> - I have written different modules like, Primary Menu, Secondary Menu etc.
> - So i can easily attach these modules to any hook with add_action(),
> depending on the requirement/presentation of a them/child theme.
>
> *Child Theme A Example*
>
> add_action('chip_header_pre', 'chip_primary_menu_init');
> add_action('chip_header_post', 'chip_secondary_menu_init');
>
> *Child Theme B Example*
>
> add_action('chip_header_pre', 'chip_secondary_menu_init');
> add_action('chip_header_post', 'chip_primary_menu_init');
>
> Both of above child themes will have different presentation of menus, with
> just a single line of code, and there may any other combination as well.
>
> *So what is the recommendation of experts to have this logic ?*
>
> --
> Regards
> Qamar Ashraf
> www.tutorialchip.com
> @lifeobject1
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110726/847a24cc/attachment-0001.htm>


More information about the theme-reviewers mailing list