Opened 13 years ago
Closed 13 years ago
#20718 closed defect (bug) (fixed)
Function get_file_description() Always Returns File Name Instead of Template Name
Reported by: | arieputranto | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | trivial | Version: | 3.4 |
Component: | Themes | Keywords: | has-patch commit |
Focuses: | Cc: |
Description (last modified by )
When there's a custom page template named "something.php" defined with
/* Template Name: Something */
On the theme editor, the file list supposed to returns:
"Something" (something.php)
where it is displaying only the file name:
"something.php"
Well it doesn't affect the functionality but it IS annoying.
I found the problem is on the:
file: wp-admin/includes/file.php
line: 62
where:
elseif ( file_exists( $file ) && is_file( $file ) ) { $template_data = implode( '', file( $file ) ); if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
Well, it will always returns the filename instead of the template name since it will never find the $file on the defined path.
It should be something like:
elseif ( file_exists( get_template_directory() . '/' . $file ) && is_file( get_template_directory() . '/' . $file ) ) { $template_data = implode( '', file( get_template_directory() . '/' . $file ) ); if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
Again, it's nothing but annoying
Attachments (1)
Change History (7)
#3
@
13 years ago
- Component changed from Administration to Themes
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 3.4
Introduced in [20313].
Note: See
TracTickets for help on using
tickets.
Found better fix.
Instead of fixing the file.php, it will be better to change the;
File: wp-admin/theme-editor.php
Line: 183
Before:
After: