Make WordPress Core

Ticket #27201: 27201.3.diff

File 27201.3.diff, 4.3 KB (added by wonderboymusic, 9 years ago)
  • src/wp-admin/includes/file.php

     
    5151 *
    5252 * @global array $wp_file_descriptions
    5353 * @param string $file Filesystem path or filename
    54  * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
     54 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.
     55 *                Appends 'Page Template' to basename of $file if the file is a page template
    5556 */
    5657function get_file_description( $file ) {
    57         global $wp_file_descriptions;
     58        global $wp_file_descriptions, $allowed_files;
    5859
    59         if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
    60                 return $wp_file_descriptions[basename( $file )];
     60        $relative_pathinfo = pathinfo( $file );
     61        $file_path = $allowed_files[ $file ];
     62        if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $relative_pathinfo['dirname'] ) {
     63                return $wp_file_descriptions[ basename( $file ) ];
     64        } elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
     65                $template_data = implode( '', file( $file_path ) );
     66                if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) {
     67                        return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) );
     68                }
    6169        }
    62         elseif ( file_exists( $file ) && is_file( $file ) ) {
    63                 $template_data = implode( '', file( $file ) );
    64                 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
    65                         return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
    66         }
    6770
    6871        return trim( basename( $file ) );
    6972}
  • src/wp-admin/theme-editor.php

     
    2525'title'         => __('Overview'),
    2626'content'       =>
    2727        '<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>
    28         <p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list then appears of all the template files. Clicking once on any file name causes the file to appear in the large Editor box.') . '</p>
     28        <p>' . __("Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list then appears of the theme's template files. Clicking once on any file name causes the file to appear in the large Editor box.") . '</p>
    2929        <p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Look Up takes you to a web page with reference material about that particular function.') . '</p>
    3030        <p id="newcontent-description">' . __( 'In the editing area the Tab key enters a tab character. To move below this area by pressing Tab, press the Esc key followed by the Tab key. In some cases the Esc key will need to be pressed twice before the Tab key will allow you to continue.' ) . '</p>
    3131        <p>' . __('After typing in your edits, click Update File.') . '</p>
     
    125125 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div>
    126126<?php endif;
    127127
    128 $description = get_file_description( $file );
     128$description = get_file_description( $relative_file );
    129129$file_show = array_search( $file, array_filter( $allowed_files ) );
    130130if ( $description != $file_show )
    131131        $description .= ' <span>(' . $file_show . ')</span>';
     
    177177                if ( 'style.css' == $filename )
    178178                        echo "\t</ul>\n\t<h2>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h2>\n\t<ul>\n";
    179179
    180                 $file_description = get_file_description( $absolute_filename );
    181                 if ( $file_description != basename( $filename ) )
     180                $file_description = get_file_description( $filename );
     181                if ( $filename !== basename( $absolute_filename ) || $file_description !== $filename ) {
    182182                        $file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>';
     183                }
    183184
    184                 if ( $absolute_filename == $file )
     185                if ( $absolute_filename === $file ) {
    185186                        $file_description = '<span class="highlight">' . $file_description . '</span>';
     187                }
    186188?>
    187189                <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&amp;theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
    188190<?php