WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7575 closed defect (bug) (fixed)

Theme Editor not displaying custom template names

Reported by: Terragg Owned by:
Milestone: 2.7 Priority: low
Severity: minor Version: 2.6.1
Component: Administration Keywords: has-patch, needs-testing
Focuses: Cc:

Description

Symptoms

Wordpress Dashboard -> Design -> Theme Editor -> Theme Files listing

Any non-standard Theme Files are listed as just the file name "my_template.php (my_template.php)" instead of "My Template (my_template.php)". This occurs despite the existence of the "/* Template Name: My Template */" code block at the beginning of the file.

Cause

The template name passed to get_file_description() in file.php from theme-editor.php lines 128 and 139 is relative to the wordpress/wp-content/ directory rather than the absolute path of the installation.

get_file_description() uses the ABSPATH to attempt to read in the file. The file can't be found and it returns the just the filename. theme-editor.php does as expected and displays the returned value as the template name.

Solution

Replace instances of ABSPATH with WP_CONTENT_PATH in the get_file_description() subroutine, as get_file_description() is only referenced in theme-editor.php.

Suggested fix in file.php.diff (attached).

Attachments (1)

file.php.diff (719 bytes) - added by Terragg 6 years ago.
svn diff output for suggested changes to file.php

Download all attachments as: .zip

Change History (5)

Terragg6 years ago

svn diff output for suggested changes to file.php

comment:1 Terragg6 years ago

  • Keywords has-patch needs-testing added

comment:2 ryan6 years ago

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

(In [8716]) Use WP_CONTENT_PATH to find find files. Props Terragg. fixes #7575 for trunk

comment:3 ryan6 years ago

  • Milestone set to 2.7

comment:4 westi6 years ago

Hmm.. WP_CONTENT_PATH. what were you smoking Ryan?

It's WP_CONTENT_DIR - fixed in [8718] - only noticed this ticket after fixing it!

Note: See TracTickets for help on using tickets.