Make WordPress Core

Ticket #27201: 27201.6.diff

File 27201.6.diff, 5.8 KB (added by MikeHansenMe, 9 years ago)
  • src/wp-admin/includes/file.php

     
    5252 *
    5353 * @uses $wp_file_descriptions
    5454 * @param string $file Filesystem path or filename
    55  * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
     55 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist,
     56 * appends 'Page Template' to basename of $file if the file is a page template
    5657 */
    5758function get_file_description( $file ) {
    58         global $wp_file_descriptions;
    59 
    60         if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
    61                 return $wp_file_descriptions[basename( $file )];
     59        global $wp_file_descriptions , $allowed_files;
     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 ) ];
    6264        }
    63         elseif ( file_exists( $file ) && is_file( $file ) ) {
    64                 $template_data = implode( '', file( $file ) );
     65        elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
     66                $template_data = implode( '', file( $file_path ) );
    6567                if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
    6668                        return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
    6769        }
  • src/wp-admin/theme-editor.php

     
    1414        exit();
    1515}
    1616
    17 if ( !current_user_can('edit_themes') )
     17if ( ! current_user_can('edit_themes') ) {
    1818        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
     19}
    1920
    2021$title = __("Edit Themes");
    2122$parent_file = 'themes.php';
     
    2425'id'            => 'overview',
    2526'title'         => __('Overview'),
    2627'content'       =>
    27         '<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>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up part of your theme.') . '</p>
     29        <p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list of php files with one level deep and css files of flat level appears . Clicking once on any file name causes the file to appear in the large Editor box.') . '</p>
    2930        <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>
    3031        <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>
    3132        <p>' . __('After typing in your edits, click Update File.') . '</p>
     
    4546
    4647wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
    4748
    48 if ( $theme )
     49if ( $theme ) {
    4950        $stylesheet = $theme;
    50 else
     51}
     52else {
    5153        $stylesheet = get_stylesheet();
     54}
    5255
    5356$theme = wp_get_theme( $stylesheet );
    5457
    55 if ( ! $theme->exists() )
     58if ( ! $theme->exists() ) {
    5659        wp_die( __( 'The requested theme does not exist.' ) );
     60}
    5761
    58 if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
     62if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) {
    5963        wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
     64}
    6065
    6166$allowed_files = $theme->get_files( 'php', 1 );
    6267$has_templates = ! empty( $allowed_files );
     
    99104
    100105        update_recently_edited( $file );
    101106
    102         if ( ! is_file( $file ) )
     107        if ( ! is_file( $file ) ) {
    103108                $error = true;
     109        }
    104110
    105111        $content = '';
    106112        if ( ! $error && filesize( $file ) > 0 ) {
     
    125131 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div>
    126132<?php endif;
    127133
    128 $description = get_file_description( $file );
     134$description = get_file_description( $relative_file );
    129135$file_show = array_search( $file, array_filter( $allowed_files ) );
    130136if ( $description != $file_show )
    131137        $description .= ' <span>(' . $file_show . ')</span>';
     
    174180        endif;
    175181
    176182        foreach ( $allowed_files as $filename => $absolute_filename ) :
    177                 if ( 'style.css' == $filename )
     183                if ( 'style.css' == $filename ) {
    178184                        echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
     185                }
    179186
    180                 $file_description = get_file_description( $absolute_filename );
    181                 if ( $file_description != basename( $filename ) )
     187                $file_description = get_file_description( $filename );
     188                if ( $filename != basename($absolute_filename) || $file_description !== $filename ) {
    182189                        $file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>';
    183 
    184                 if ( $absolute_filename == $file )
     190                }
     191                if ( $absolute_filename == $file ) {
    185192                        $file_description = '<span class="highlight">' . $file_description . '</span>';
     193                }
    186194?>
    187195                <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&amp;theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
    188196<?php
     
    238246break;
    239247}
    240248
    241 include(ABSPATH . 'wp-admin/admin-footer.php' );
     249include(ABSPATH . 'wp-admin/admin-footer.php' );
     250 No newline at end of file