Display a smaller filename in the theme editor urls and make theme files editable again. Fixes #10974.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ce94d9ca5c
commit
a2e61f480c
|
@ -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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -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 ) ) :
|
||||
?>
|
||||
<li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
|
||||
<li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&theme=<?php echo urlencode($theme) ?>&dir=theme"><?php echo $filedesc ?></a></li>
|
||||
<?php endwhile; ?>
|
||||
</ul>
|
||||
<h4><?php /* translators: Theme stylesheets in theme editor */ echo _x('Styles', 'Theme stylesheets in theme editor'); ?></h4>
|
||||
<ul>
|
||||
<?php
|
||||
$template_mapping = array();
|
||||
$stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
|
||||
foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
|
||||
$description = trim( get_file_description($style_file) );
|
||||
$style_show = basename($style_file);
|
||||
$filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
|
||||
$filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
|
||||
$template_mapping[ $description ] = array( $style_file, $filedesc );
|
||||
$template_mapping[ $description ] = array( _get_template_edit_filename($style_file, $style_file), $filedesc );
|
||||
}
|
||||
ksort( $template_mapping );
|
||||
while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
|
||||
?>
|
||||
<li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
|
||||
<li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&theme=<?php echo urlencode($theme) ?>&dir=style"><?php echo $filedesc ?></a></li>
|
||||
<?php endwhile; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
|
Loading…
Reference in New Issue