[wp-trac] [WordPress Trac] #20718: Function get_file_description() Always Returns File Name Instead of Template Name

WordPress Trac wp-trac at lists.automattic.com
Mon May 21 10:00:29 UTC 2012


#20718: Function get_file_description() Always Returns File Name Instead of
Template Name
----------------------------+--------------------------------------
 Reporter:  arieputranto    |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  3.4
 Severity:  trivial         |   Keywords:  dev-feedback needs-patch
----------------------------+--------------------------------------
 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

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20718>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list