WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 8 months ago

Last modified 8 months ago

#39525 closed enhancement (fixed)

Send template candidates along with {$type}_template filter

Reported by: mschadegg Owned by: johnbillion
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.8
Component: Themes Keywords: has-patch
Focuses: template Cc:

Description

For many use case, it will be good, if the template candidates is used as second parameter in the {$type}_template filter.

Maybe the the type should be used as a parameter as well, but it is possible to get the type by calling current_filter() function.

Attachments (2)

template.php.patch (501 bytes) - added by mschadegg 9 months ago.
Patch with template candidates as second parameter.
template.php.2.patch (563 bytes) - added by mschadegg 9 months ago.
Type as second parameter and template candidates as third parameter.

Download all attachments as: .zip

Change History (7)

@mschadegg
9 months ago

Patch with template candidates as second parameter.

@mschadegg
9 months ago

Type as second parameter and template candidates as third parameter.

#1 @mschadegg
9 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
9 months ago

Hi @mschadegg, welcome to Trac! Thanks for the ticket.

A separate {$type}_template_hierarchy filter for template candidates was introduced in [38385], is it not sufficient in your case?

#3 @mschadegg
9 months ago

I have used that filter, to save the hierarchy as a property in a class, so I can use it in the other filter afterwards. So yes, it makes it possible to do what I want to accomplish, but I don't think it is a proper way to do it.

#4 @johnbillion
8 months ago

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

In 40057:

Themes: Add template type and template candidates as parameters to the {$type}_template filter.

Props mschadegg
Fixes #39525

#5 @johnbillion
8 months ago

  • Milestone changed from Awaiting Review to 4.8
Note: See TracTickets for help on using tickets.