WordPress.org

Make WordPress Core

Opened 4 weeks ago

Closed 4 weeks ago

#43872 closed enhancement (fixed)

Add page template filter for all post types

Reported by: desrosj Owned by: desrosj
Milestone: 4.9.6 Priority: normal
Severity: normal Version: 4.7
Component: Themes Keywords: has-patch fixed-major
Focuses: template Cc:

Description

In 4.7, a dynamic filter was introduced that filters page templates. It would be great if there were a filter for all post types as well.

Use case: I have a page template in a theme that uses a class in a plugin. If the plugin is not present on the site, that page template should be filtered out of the page template list. Right now, you have to register a filter for every post type.

Related: #18375

Attachments (1)

43872.diff (1.5 KB) - added by desrosj 4 weeks ago.

Download all attachments as: .zip

Change History (7)

@desrosj
4 weeks ago

#1 @desrosj
4 weeks ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to desrosj
  • Status changed from new to assigned

43872.diff introduces a theme_templates filter for filtering page templates regardless of post type.

#2 @desrosj
4 weeks ago

  • Type changed from defect (bug) to enhancement

#3 @SergeyBiryukov
4 weeks ago

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

In 43025:

Themes: Introduce theme_templates filter for page templates of all post types.

This complements the theme_{$post_type}_templates dynamic filter added in [38951].

Props desrosj.
Fixes #43872.

#4 @SergeyBiryukov
4 weeks ago

  • Keywords fixed-major added
  • Milestone changed from 5.0 to 4.9.6
  • Resolution fixed deleted
  • Status changed from closed to reopened

Looks like we have a precedent of adding new hooks in recent minor releases, see [42589] for example.

This seems like a good enhancement for 4.9.6.

#5 @SergeyBiryukov
4 weeks ago

In 43027:

Docs: Update @since version for theme_templates filter added in [43025].

See #43872.

#6 @SergeyBiryukov
4 weeks ago

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

In 43028:

Themes: Introduce theme_templates filter for page templates of all post types.

This complements the theme_{$post_type}_templates dynamic filter added in [38951].

Props desrosj.
Merges [43025] and [43027] to the 4.9 branch.
Fixes #43872.

Note: See TracTickets for help on using tickets.