diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 57e3fa7991..4593feee52 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -146,4 +146,18 @@ function get_page_templates() { return $page_templates; } +/** + * Tidies a filename for url display by the theme editor. + * + * @since 2.9.0 + * @private + * + * @param string $fullpath Full path to the theme file + * @param string $containingfolder Path of the theme parent folder + * @return string + */ +function _get_template_edit_filename($fullpath, $containingfolder) { + return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath); +} + ?> diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php index a78f16eb0c..4b2f06e02f 100644 --- a/wp-admin/theme-editor.php +++ b/wp-admin/theme-editor.php @@ -15,7 +15,7 @@ if ( !current_user_can('edit_themes') ) $title = __("Edit Themes"); $parent_file = 'themes.php'; -wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme')); +wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme', 'dir')); wp_admin_css( 'theme-editor' ); @@ -34,10 +34,15 @@ $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme if (empty($file)) { $file = $allowed_files[0]; +} else { + if ( 'theme' == $dir ) { + $file = dirname(dirname($themes[$theme]['Template Dir'])) . $file ; + } else if ( 'style' == $dir) { + $file = dirname(dirname($themes[$theme]['Stylesheer Dir'])) . $file ; + } } -$file = validate_file_to_edit($file, $allowed_files); -$real_file = get_real_file_to_edit($file); +$real_file = validate_file_to_edit($file, $allowed_files); $scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0; $file_show = basename( $file ); @@ -157,33 +162,34 @@ if ($allowed_files) : // This means that we display the correct files for child themes which overload Templates as well as Styles if( array_key_exists($description, $template_mapping ) ) { if ( false !== strpos( $template_file, $template_dir ) ) { - $template_mapping[ $description ] = array( $template_file, $filedesc ); + $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); } } else { - $template_mapping[ $description ] = array( $template_file, $filedesc ); + $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc ); } } ksort( $template_mapping ); while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) : ?> -