WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16607 closed defect (bug) (fixed)

Theme Editor fails to list child theme files if the child theme dir starts with the parent theme dir name

Reported by: chrisjean Owned by: nacin
Milestone: 3.1 Priority: normal
Severity: major Version: 3.1
Component: Editor Keywords: has-patch commit
Focuses: Cc:

Description

r16714 introduced a new bug. The following line of code (used for both template and style files) fails when compared against child themes that start with the same name as their parent (such as Theme and ThemeChild):

if ( $is_child_theme && strpos( $style_file, $themes[$theme]['Template Dir'] ) === 0 )

This results in no files being listed for the child theme.

The fix-child-theme-editor.diff patch addresses this issue by using trailingslashit on the template directory string, thus allowing a proper check to be done:

if ( $is_child_theme && strpos( $style_file, trailingslashit( $themes[$theme]['Template Dir'] ) ) === 0 )

Attachments (1)

fix-child-theme-editor.diff (1.1 KB) - added by chrisbliss18 3 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 chrisbliss183 years ago

I should clarify that the name I refer to in the initial patch isn't the theme name itself but the directory name.

comment:2 ocean903 years ago

  • Cc nacin added

comment:3 nacin3 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Owner set to nacin
  • Status changed from new to reviewing

comment:4 nacin3 years ago

  • Keywords commit added
  • Status changed from reviewing to accepted

Thanks Chris. Tested, looks good.

comment:5 chrisbliss183 years ago

Thanks for your rapid response nacin. This would be a problem for many of our users if it made it into release.

comment:6 scribu3 years ago

  • Severity changed from major to normal

comment:7 nacin3 years ago

  • Severity changed from normal to major

Also testing this on a PC due to the change in directory separators. Looks good. Template file looks like this:

C:\xampp\htdocs\trunk/wp-content/themes/twentyten/404.php

And template dir looks like:

C:\xampp\htdocs\trunk/wp-content/themes/twentyten

Adding a trailing slash takes care of it.

(At worst, it fails, and the parent template shows anyway.)

Looking into this further, it looks like I set up a variable but never used it. Going to clean that up on commit.

comment:8 nacin3 years ago

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

(In [17470]) Ensure we're matching the complete theme directory when excluding parent templates from the theme editor. props chrisbliss18, fixes #16607 for the 3.1 branch.

comment:9 nacin3 years ago

(In [17471]) Ensure we're matching the complete theme directory when excluding parent templates from the theme editor. props chrisbliss18, fixes #16607 for trunk.

Note: See TracTickets for help on using tickets.