Ticket #6945 (reopened enhancement)

Opened 2 months ago

Last modified 1 week ago

Add wp_header hook

Reported by: sirzooro Assigned to: anonymous
Priority: normal Milestone: 2.7
Component: General Version: 2.5.1
Severity: normal Keywords: dev-feedback
Cc:

Description

This new hook should be called just after <body> tag is printed. I am going to print some HTML code at the very beginning of every page, without the need to change every theme I use. This new function will be a great addition for Header-Footer plugin (http://wordpress.org/extend/plugins/header-footer/) too.

Change History

05/10/08 02:26:55 changed by Viper007Bond

-1. Very fringe case and I don't see the hook being used on a regular basis. Plus, since this is a theme hook, it's up to the theme developer to add the hook to their theme. I still very often come across themes without the head and footer hooks and those have been around since the dawn of time.

If you need this just for your site, then just modify your themes you use. Hooks aren't registered anywhere -- you can make up your own ones. Just add <?php do_action('your_hook'); ?> to each of your themes and then use the hook.

If you're writing a plugin to be distributed, then you should either have the user edit their theme and add a function where they want your plugin to output or you should use ob_start() or whatever it is to add in the HTML yourself.

Recommend "wontfix".

06/06/08 16:37:56 changed by JohnLamansky

+1 for wontfix

In addition to what Viper007Bond said, a wp_header hook could create confusion with the existing wp_head hook.

I am going to print some HTML code at the very beginning of every page, without the need to change every theme I use.

Since this is a theme hook, you'd have to change your themes anyway.

06/07/08 02:35:33 changed by Viper007Bond

  • status changed from new to closed.
  • resolution set to wontfix.
  • milestone deleted.

Gonna just close this as "wontfix". There hasn't been any reporter feedback and I think my point is valid.

(follow-up: ↓ 6 ) 06/14/08 09:54:07 changed by sirzooro

  • status changed from closed to reopened.
  • resolution deleted.

@Viper007Bond: I haven't responded yet because I assumed that your comment was a general opinion and it doesn't require any response from my side. My fault :)

@JohnLamansky?: I haven't pointed this earlier, but this change would be useful if you use single WP installation to handle multiple domains (e.g. WP MU) - in this case this feature would be the only way to add html code just after <body> if you want to reuse themes on blogs.

I know that wp_header name may be confused with existing wp_head, but on the other hand it is consistent with wp_footer. Of course you can use a better one if you have it.

06/14/08 12:07:50 changed by DD32

I tend to agree with the wontfix close.

The theme itself needs to add the hook, and adding it to the default themes will have little use in terms of mass-adotption.

If a WPMU hoster wants to use that hook, then they can add it to the themes they offer, Chances are, It'd be a fair ammount of time until most general themes added it at all.

(in reply to: ↑ 4 ) 06/14/08 23:29:50 changed by strider72

Replying to sirzooro:

[T]his change would be useful if you use single WP installation to handle multiple domains (e.g. WP MU) - in this case this feature would be the only way to add html code just after <body> if you want to reuse themes on blogs.

There's another patch somewhere for changing the way "child themes" work. Rather than only being able to overwrite CSS nad basing the HTML on another theme, you would be able to write, for example, a header.php file for the child theme and it will override the corresponding file from the parent theme.

I would check into that -- it's an excellent fix for exactly the situation you describe.

06/25/08 03:16:08 changed by DD32

  • keywords set to dev-feedback.
  • milestone set to 2.7.