Ticket #27201: 27201.6.diff
File 27201.6.diff, 5.8 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/file.php
52 52 * 53 53 * @uses $wp_file_descriptions 54 54 * @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 56 57 */ 57 58 function 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 ) ]; 62 64 } 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 ) ); 65 67 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) 66 68 return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); 67 69 } -
src/wp-admin/theme-editor.php
14 14 exit(); 15 15 } 16 16 17 if ( ! current_user_can('edit_themes') )17 if ( ! current_user_can('edit_themes') ) { 18 18 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>'); 19 } 19 20 20 21 $title = __("Edit Themes"); 21 22 $parent_file = 'themes.php'; … … 24 25 'id' => 'overview', 25 26 'title' => __('Overview'), 26 27 '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> 29 30 <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> 30 31 <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> 31 32 <p>' . __('After typing in your edits, click Update File.') . '</p> … … 45 46 46 47 wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) ); 47 48 48 if ( $theme ) 49 if ( $theme ) { 49 50 $stylesheet = $theme; 50 else 51 } 52 else { 51 53 $stylesheet = get_stylesheet(); 54 } 52 55 53 56 $theme = wp_get_theme( $stylesheet ); 54 57 55 if ( ! $theme->exists() ) 58 if ( ! $theme->exists() ) { 56 59 wp_die( __( 'The requested theme does not exist.' ) ); 60 } 57 61 58 if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) 62 if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() ) { 59 63 wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() ); 64 } 60 65 61 66 $allowed_files = $theme->get_files( 'php', 1 ); 62 67 $has_templates = ! empty( $allowed_files ); … … 99 104 100 105 update_recently_edited( $file ); 101 106 102 if ( ! is_file( $file ) ) 107 if ( ! is_file( $file ) ) { 103 108 $error = true; 109 } 104 110 105 111 $content = ''; 106 112 if ( ! $error && filesize( $file ) > 0 ) { … … 125 131 <div id="message" class="updated notice is-dismissible"><p><?php _e( 'File edited successfully.' ) ?></p></div> 126 132 <?php endif; 127 133 128 $description = get_file_description( $ file );134 $description = get_file_description( $relative_file ); 129 135 $file_show = array_search( $file, array_filter( $allowed_files ) ); 130 136 if ( $description != $file_show ) 131 137 $description .= ' <span>(' . $file_show . ')</span>'; … … 174 180 endif; 175 181 176 182 foreach ( $allowed_files as $filename => $absolute_filename ) : 177 if ( 'style.css' == $filename ) 183 if ( 'style.css' == $filename ) { 178 184 echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n"; 185 } 179 186 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 ) { 182 189 $file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>'; 183 184 if ( $absolute_filename == $file ) 190 } 191 if ( $absolute_filename == $file ) { 185 192 $file_description = '<span class="highlight">' . $file_description . '</span>'; 193 } 186 194 ?> 187 195 <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li> 188 196 <?php … … 238 246 break; 239 247 } 240 248 241 include(ABSPATH . 'wp-admin/admin-footer.php' ); 249 include(ABSPATH . 'wp-admin/admin-footer.php' ); 250 No newline at end of file