Ticket #27201: 27201.patch
File 27201.patch, 5.7 KB (added by , 11 years ago) |
---|
-
includes/file.php
53 53 * @uses _cleanup_header_comment 54 54 * @uses $wp_file_descriptions 55 55 * @param string $file Filesystem path or filename 56 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist 56 * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist, 57 * appends 'Page Template' to basename of $file if the file is a page template 57 58 */ 58 59 function get_file_description( $file ) { 59 global $wp_file_descriptions; 60 61 if ( isset( $wp_file_descriptions[basename( $file )] ) ) { 62 return $wp_file_descriptions[basename( $file )]; 60 global $wp_file_descriptions , $allowed_files; 61 $relative_pathinfo = pathinfo( $file ); 62 $file_path = $allowed_files[ $file ]; 63 if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' == $relative_pathinfo['dirname'] ) { 64 return $wp_file_descriptions[ basename( $file ) ]; 63 65 } 64 elseif ( file_exists( $file ) && is_file( $file) ) {65 $template_data = implode( '', file( $file ) );66 elseif ( file_exists( $file_path ) && is_file( $file_path) ) { 67 $template_data = implode( '', file( $file_path ) ); 66 68 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) 67 69 return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); 68 70 } … … 1109 1111 </form> 1110 1112 <?php 1111 1113 return false; 1112 } 1114 } 1115 No newline at end of file -
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.') . '</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 ); … … 100 105 101 106 update_recently_edited( $file ); 102 107 103 if ( ! is_file( $file ) ) 108 if ( ! is_file( $file ) ) { 104 109 $error = true; 110 } 105 111 106 112 $content = ''; 107 113 if ( ! $error && filesize( $file ) > 0 ) { … … 127 133 <div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div> 128 134 <?php endif; 129 135 130 $description = get_file_description( $ file );136 $description = get_file_description( $relative_file ); 131 137 $file_show = array_search( $file, array_filter( $allowed_files ) ); 132 138 if ( $description != $file_show ) 133 139 $description .= ' <span>(' . $file_show . ')</span>'; … … 176 182 endif; 177 183 178 184 foreach ( $allowed_files as $filename => $absolute_filename ) : 179 if ( 'style.css' == $filename ) 185 if ( 'style.css' == $filename ) { 180 186 echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n"; 187 } 181 188 182 $file_description = get_file_description( $ absolute_filename );183 if ( $file _description != basename( $filename ) )189 $file_description = get_file_description( $filename ); 190 if ( $filename != basename($absolute_filename) || $file_description !== $filename ) { 184 191 $file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>'; 185 186 if ( $absolute_filename == $file ) 192 } 193 if ( $absolute_filename == $file ) { 187 194 $file_description = '<span class="highlight">' . $file_description . '</span>'; 195 } 188 196 ?> 189 197 <li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li> 190 198 <?php … … 242 250 break; 243 251 } 244 252 245 include(ABSPATH . 'wp-admin/admin-footer.php' ); 253 include(ABSPATH . 'wp-admin/admin-footer.php' ); 254 No newline at end of file