Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#43872 closed enhancement (fixed)

Add page template filter for all post types

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

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 8 years ago.

Download all attachments as: .zip

Change History (7)

@desrosj
8 years ago

#1 @desrosj
8 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review5.0
  • Owner set to desrosj
  • Status newassigned

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

#2 @desrosj
8 years ago

  • Type defect (bug)enhancement

#3 @SergeyBiryukov
8 years ago

  • Resolutionfixed
  • Status assignedclosed

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
8 years ago

  • Keywords fixed-major added
  • Milestone 5.04.9.6
  • Resolution fixed
  • Status closedreopened

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
8 years ago

In 43027:

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

See #43872.

#6 @SergeyBiryukov
8 years ago

  • Resolutionfixed
  • Status reopenedclosed

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.