Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#10215 closed defect (bug) (duplicate)

Page Templates found in sub-dirs, but not usable

Reported by: alexkingorg's profile alexkingorg Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Template Keywords:
Focuses: Cc:

Description

Apologies if this is a duplicate - I tried to search but did not find anything applicable.

In 2.8, the page template drop down lists page templates in sub-directories where in previous versions only page templates in the theme root dir were listed. This is a good change (IMO).

However, the implementation of this is not working properly as only the filename of the page template is in the drop-down and stored for the post, rather than the dir name and the file name:

pages/my-page.php

<option value="my-page.php">My Page</option>

instead of:

<option value="pages/my-page.php">My Page</option>

Because of this, the selected sub-dir page template does not get properly applied.

I've been meaning to try to debug and get a patch, but haven't had a chance yet and hear that the 2.8.1 release is looming, so wanted to get this submitted.

I just confirmed this is still broken in current trunk 2009-06-18.

Change History (5)

#1 @Denis-de-Bernardy
16 years ago

  • Milestone changed from Unassigned to 2.9
  • Priority changed from high to normal

this sounds like an unexpected side effect.

#2 @dd32
16 years ago

This is caused by basename() on line 139: http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/theme.php#L139

that could be changed like such:

			if ( !empty( $name ) ) {
				$template = preg_replace('#^' . preg_quote(get_theme_root(), '#') . '/[^/]+/#i', '', WP_CONTENT_DIR . $template);
				$page_templates[trim( $name )] = $template;
			}

and it'll work as expected..

but i'm questioning this entire function logic at present, get_theme_root() allows you to filter on 'theme_root' which allows you to move it out of WP_CONTENT_DIR.. right now, this is not respecting that at all due to the hard-coded WP_CONTENT_DIR, Thus my usage of get_theme_root() there.. But its still got a hard-coded dir...

#3 @dd32
16 years ago

Also have to be careful of templates from parent themes.. see how they get mangled by that..

#4 @lloydbudd
15 years ago

No patch... bumping out of milestone.

#5 @nacin
15 years ago

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

Fixed in #10959 by removing the option to select a page template in a subdirectory.

Note: See TracTickets for help on using tickets.