Page 1 of 4 123 ... LastLast
Results 1 to 10 of 34

Thread: Standard Theme Hook Names

  1. #1
    Join Date
    Jan 2009
    Location
    USA
    Posts
    237

    Default Standard Theme Hook Names

    More and more themes are putting hooks in their themes, but when they do this they use their own naming convention. Theme developers and WordPress.org should pack together and create a standard naming convention for the most common ones. It would do a big favour to the people who use these hooks and even move it away from just personal use, plugin developers could then start to take advantage of these hooks in themes.

    Examples would be something like
    Code:
    theme_belowheader()
    theme_abovecomments()
    theme_abovecommentslist()
    theme_belowcommentslist()
    theme_abovetrackbackslist()
    theme_belowtrackbackslist()
    theme_abovecommentsform()
    theme_show_subscription_checkbox()
    theme_belowcommentsform()
     ...
    Better earlier rather than later. Anyone for this idea?
    Dan Cole, Future Engineer.

  2. #2
    Join Date
    Feb 2009
    Location
    Mississauga, ON, CANADA
    Posts
    349

    Default

    Seems like the idea has merit.

    Not sure what the standard(s) should be for the naming conventions, your ideas are as good a place as any to start. Although I tend to lean more to clearer variable naming ... maybe add more underscores or hyphens for cleaner separations.

    (I'd say a form of "camelCode" but I find that hard to read as well ... still getting use to XCode )

  3. #3
    Join Date
    Jan 2009
    Location
    USA
    Posts
    237

    Default

    I actually took that from Thematic to tell you the truth. I just replace Thematic with Theme. I also looked through Thesis and his hooks have similar names, just with Thesis instead of Thematic or Theme. Hybrid Themes doesn't allow viewing of the page with a list of hook names, but based on a single comment, which is public, he used the same convention with hybrid in there.

    I just think we could standardize the where these hooks are located and the names, even if it does include the theme name, because people could just use "variable variables".

    I'd like to know which theme developers would support this. Then create a list of hook names here, then publish them on WordPress.org's Codex.
    Dan Cole, Future Engineer.

  4. #4
    Join Date
    Jan 2009
    Location
    Terre Haute, IN
    Posts
    354

    Default

    I would go for something that didn't specify location, like "theme_beforeheader" etc. But the idea of a unified hook system is a good one.

    IMHO a really good theme should also include some filters to make the theme as customizable as possible. These could also be given a unified naming convention, though there would probably be a lot more of them. What do you think?

  5. #5
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    I've been contemplating adopting Justin Tadlocks Theme Hybrid hook names for this purpose. It would make a lot more sense to use a generic set of hooks though.

    Perhaps if we could come up with a set of hook names that we agree on we could forward them to WordPress.org as a recommendation? I'm guessing this wouldn't be something for trac since it would be a recommendation rather than anything actually included in the WP core.

    My Multi-level Navigation Plugin would be ideally suited for something like this as at the moment I ask users to modify their theme code just to get the plugin working, but if there was a standardised hook for the part of the theme users are most likely to want a menu to appear then I could have the plugin automatically add itself to a users site and they'd only need to modify their theme if it didn't support the 'standardised hooks' or if the particular place the theme added the hooks caused problems.

  6. #6
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    that would be pretty darn awesome. I can immediately see the benefits in a WPMU system, too.

  7. #7
    Join Date
    Jan 2009
    Location
    Huddersfield, West Yorkshire
    Posts
    70

    Default

    I agree that something other than a location based system would be good but I don't really have any suggestions.

  8. #8
    Join Date
    Jan 2009
    Location
    USA
    Posts
    237

    Default

    To start on the naming... I see hook names defined by what the code they insert does or what is happening when they insert code. WordPress often includes "wp_" at the beginning to make sure it's unique, but also show it's a Core WordPress action.


    • Should these actions start with "theme_"?

    It would make sure they are unique, but it may not be necessary.

    • How should pre and post actions be dealt with?

    include the words "before" and after" or "pre" and "post" or "start and end"

    • Where will the pre and post words be located in the action name?

    Thematic example: "thematic_belowheader". WP examples: "wp_start" and "pre_get_posts".

    • How should the core name be setup?

    it seams like WordPress like to keep them short and descriptive. Separate words are often separated with an underscore. Noting: http://codex.wordpress.org/Plugin_API/Action_Reference
    Dan Cole, Future Engineer.

  9. #9
    Join Date
    Jan 2009
    Location
    USA
    Posts
    237

    Default

    To help see where everyone stands on this issue and to help see everyone's view on the questions I asked in my last post, here is a 8 question survey that should only take a minute or two.

    Last edited by dancole; 05-20-2009 at 04:16 PM.
    Dan Cole, Future Engineer.

  10. #10
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Thanks for doing this Dan. I've voted, but am pretty flexible on that stuff, as long as it is consistent and officially recommended by WordPress.org then I'll be happy.

    I guess the next poll would be to get an idea of what specific hooks and filters would be best to recommend.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •