WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 7 months ago

#41575 closed enhancement (fixed)

Add global action to get_template_part

Reported by: pcfreak30 Owned by: johnbillion
Milestone: 5.2 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: template Cc:
PR Number:

Description

I would like to see

do_action( "get_template_part", $slug, $name );

in get_template_part. Right now there is no means to track or do any action on every template call. A feature I want to implement in a plugin relies on this to function how I want. As of now I can only get the primary template.

Attachments (1)

41575.diff (741 bytes) - added by jdeeburke 14 months ago.

Download all attachments as: .zip

Change History (12)

#2 @joyously
2 years ago

That is very similar to what is there now:
do_action( "get_template_part_{$slug}", $slug, $name );
but I can see that it would be difficult to do a generic action since the slug is part of the action name.
Reviewing themes, I have seen quite a variety of slugs used, mostly with a folder structure. This really does not lend itself to reuse.

#3 @johnbillion
14 months ago

  • Keywords needs-patch good-first-bug added

I think it's time that this happened. It can really help with debugging and analysis.

@jdeeburke
14 months ago

#4 @jdeeburke
14 months ago

  • Keywords has-patch added; needs-patch removed

#5 @johnbillion
14 months ago

  • Keywords good-first-bug removed
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to johnbillion
  • Status changed from new to reviewing

#6 @johnbillion
13 months ago

  • Milestone changed from 5.0 to 5.1

#7 @pento
10 months ago

  • Milestone changed from 5.1 to 5.2

#8 @johnbillion
8 months ago

  • Version 4.9 deleted

#9 @desrosj
7 months ago

  • Milestone changed from 5.2 to 5.3

This ticket has not received any attention during the 5.2 cycle. With beta
1 tomorrow, going to punt this to 5.3.

#10 @johnbillion
7 months ago

  • Milestone changed from 5.3 to 5.2

Enough with the bumping.

#11 @johnbillion
7 months ago

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

In 45059:

Themes: Introduce a generic action that's fired when a template part is loaded.

This action allows debugging mechanisms to perform greater introspection into which template parts are loaded for any given request. It also exposes the array of candidate template part file names for each template part instance.

Props pcfreak30, jdeeburke

Fixes #41575

Note: See TracTickets for help on using tickets.