WordPress.org

Make WordPress Core

Changeset 12063


Ignore:
Timestamp:
10/19/2009 09:39:04 PM (9 years ago)
Author:
westi
Message:

Display a smaller filename in the theme editor urls and make theme files editable again. Fixes #10974.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/theme.php

    r12033 r12063  
    147147}
    148148
     149/**
     150 * Tidies a filename for url display by the theme editor.
     151 *
     152 * @since 2.9.0
     153 * @private
     154 *
     155 * @param string $fullpath Full path to the theme file
     156 * @param string $containingfolder Path of the theme parent folder
     157 * @return string
     158 */
     159function _get_template_edit_filename($fullpath, $containingfolder) {
     160    return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath);
     161}
     162
    149163?>
  • trunk/wp-admin/theme-editor.php

    r12005 r12063  
    1616$parent_file = 'themes.php';
    1717
    18 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
     18wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme', 'dir'));
    1919
    2020wp_admin_css( 'theme-editor' );
     
    3535if (empty($file)) {
    3636    $file = $allowed_files[0];
    37 }
    38 
    39 $file = validate_file_to_edit($file, $allowed_files);
    40 $real_file = get_real_file_to_edit($file);
     37} else {
     38    if ( 'theme' == $dir ) {
     39        $file = dirname(dirname($themes[$theme]['Template Dir'])) . $file ;
     40    } else if ( 'style' == $dir) {
     41        $file = dirname(dirname($themes[$theme]['Stylesheer Dir'])) . $file ;
     42    }
     43}
     44
     45$real_file = validate_file_to_edit($file, $allowed_files);
    4146$scrollto = isset($_REQUEST['scrollto']) ? (int) $_REQUEST['scrollto'] : 0;
    4247
     
    158163        if( array_key_exists($description, $template_mapping ) ) {
    159164            if ( false !== strpos( $template_file, $template_dir ) )  {
    160                 $template_mapping[ $description ] = array( $template_file, $filedesc );
     165                $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
    161166            }
    162167        } else {
    163             $template_mapping[ $description ] = array( $template_file, $filedesc );
     168            $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
    164169        }
    165170    }
     
    167172    while ( list( $template_sorted_key, list( $template_file, $filedesc ) ) = each( $template_mapping ) ) :
    168173    ?>
    169         <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
     174        <li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>&amp;dir=theme"><?php echo $filedesc ?></a></li>
    170175<?php endwhile; ?>
    171176    </ul>
     
    174179<?php
    175180    $template_mapping = array();
     181    $stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
    176182    foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
    177183        $description = trim( get_file_description($style_file) );
     
    179185        $filedesc = ( $description != $style_file ) ? "$description <span class='nonessential'>($style_show)</span>" : "$description";
    180186        $filedesc = ( $style_file == $file ) ? "<span class='highlight'>$description <span class='nonessential'>($style_show)</span></span>" : $filedesc;
    181         $template_mapping[ $description ] = array( $style_file, $filedesc );
     187        $template_mapping[ $description ] = array( _get_template_edit_filename($style_file, $style_file), $filedesc );
    182188    }
    183189    ksort( $template_mapping );
    184190    while ( list( $template_sorted_key, list( $style_file, $filedesc ) ) = each( $template_mapping ) ) :
    185191        ?>
    186         <li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
     192        <li><a href="theme-editor.php?file=<?php echo "$style_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>&amp;dir=style"><?php echo $filedesc ?></a></li>
    187193<?php endwhile; ?>
    188194    </ul>
Note: See TracChangeset for help on using the changeset viewer.