Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#27322 closed enhancement (duplicate)

Allow modifying the theme directory stack

Reported by: rmccue's profile rmccue Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch
Focuses: Cc:


Currently, all internal functions first search the current theme's directory for a file, then the current parent's directory. This step is done manually in things like locate_template, comments_template and others.

I'd like to propose adding the ability to override this stack. For plugins that want to add default templates, they can add this to the bottom of the stack and ensure that it works perfectly across the template loader and other functions (such as get_template_part). It also allows writing plugins to handle more complicated theme hierarchies.

WordPress itself can take advantage of this by adding the theme-compat directory to the bottom of the stack, allowing fallbacks for things like the comment template/etc without needing the custom code that currently exists.

Note that unlike #13239, this does not allow overriding the template hierarchy, only the theme hierarchy.

Along with this, it makes sense to introduce a theme_url function along the lines of #18302. I have included that here, since it makes more sense to bundle these changes together, IMO.

Patch attached. No unit tests currently.

Attachments (1)

27322.diff (2.3 KB) - added by rmccue 10 years ago.
Proof-of-concept patch

Download all attachments as: .zip

Change History (8)

10 years ago

Proof-of-concept patch

This ticket was mentioned in IRC in #wordpress-dev by rmccue. View the logs.

10 years ago

#2 @rmccue
10 years ago

(Note that the attached patch only changes locate_template. There are other occurrences to replace if we want to go all in on the stack.)

#3 @MikeSchinkel
10 years ago

Really nice! +1

#5 @nacin
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Yeah, turns out this is a duplicate of #22355.

#6 @rmccue
10 years ago

Dang, knew I saw this somewhere before but couldn't find anything. Transferring patch.

This ticket was mentioned in Slack in #core by rmccue. View the logs.

10 years ago

Note: See TracTickets for help on using tickets.