Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12248 closed defect (bug) (fixed)

get_generic_template action should pass both slug and name as parameters

Reported by: ptahdunbar's profile ptahdunbar Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Template Keywords: has-patch
Focuses: Cc:

Description

get_generic_template() has a do_action call that gets fired when it's used.
do_action( "get_generic_template_{$slug}", $name );

I propose to change it into this:
do_action( 'get_generic_template', $slug, $name );

So other themes and plugins can easily hook into the 'get_generic_template' and run code without initially having to know the slug.

Attachments (1)

get_generic_template_patch.diff (757 bytes) - added by ptahdunbar 15 years ago.

Download all attachments as: .zip

Change History (5)

#1 @hakre
15 years ago

Related: #12105

#2 follow-up: @westi
15 years ago

I am strongly against having an action in this function which gets called whatever the $slug.

I am quite happy to add the $slug as one of the arguments probably after the name so if people want to hook the same function on twice they can.

We shouldn't encourage people to hook into a really generic action here to do things they should be hooking in for specific situations where they need to do something.

Otherwise we end up calling a lot of code unnecessarily.

#3 in reply to: ↑ 2 @ptahdunbar
15 years ago

Replying to westi:

I am strongly against having an action in this function which gets called whatever the $slug.
...
We shouldn't encourage people to hook into a really generic action here to do things they should be hooking in for specific situations where they need to do something.

Otherwise we end up calling a lot of code unnecessarily.

Ok, that's a compromise. However, there _needs_ to be a filter. Related: #11242

#4 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [14047]) Tweaks to the action in get_template_part(). fixes #12248, fixes #12941.

Note: See TracTickets for help on using tickets.