Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r17471 r15135  
    1010require_once('./admin.php');
    1111
    12 if ( is_multisite() && ! is_network_admin() ) {
    13         wp_redirect( network_admin_url( 'theme-editor.php' ) );
    14         exit();
    15 }
    16 
    1712if ( !current_user_can('edit_themes') )
    1813        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
     
    2722$help .= '<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>';
    2823$help .= '<p>' . __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="http://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> instead.') . '</p>';
    29 if ( is_network_admin() )
    30         $help .= '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>';
    3124$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
    3225$help .= '<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>';
     
    5245        wp_die(__('The requested theme does not exist.'));
    5346
    54 $allowed_files = array_merge( $themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files'] );
    55 
    56 if ( empty( $file ) ) {
    57         if ( false !== array_search( $themes[$theme]['Stylesheet Dir'] . '/style.css', $allowed_files ) )
    58                 $file = $themes[$theme]['Stylesheet Dir'] . '/style.css';
    59         else
    60                 $file = $allowed_files[0];
     47$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
     48
     49if (empty($file)) {
     50        $file = $allowed_files[0];
    6151} else {
    6252        $file = stripslashes($file);
     
    10494default:
    10595
    106         require_once(ABSPATH . 'wp-admin/admin-header.php');
     96        require_once('./admin-header.php');
    10797
    10898        update_recently_edited($file);
     
    111101                $error = 1;
    112102
    113         $content = '';
    114103        if ( !$error && filesize($file) > 0 ) {
    115104                $f = fopen($file, 'r');
     
    127116                }
    128117
    129                 $content = esc_textarea( $content );
     118                $content = htmlspecialchars( $content );
    130119        }
    131120
     
    136125
    137126$description = get_file_description($file);
    138 $desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show;
    139 
    140 $is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet'];
     127$desc_header = ( $description != $file_show ) ? "<strong>$description</strong> (%s)" : "%s";
    141128?>
    142129<div class="wrap">
     
    146133<div class="fileedit-sub">
    147134<div class="alignleft">
    148 <h3><?php echo $themes[$theme]['Name'] . ': ' . $desc_header; ?></h3>
     135<big><?php echo sprintf($desc_header, $file_show); ?></big>
    149136</div>
    150137<div class="alignright">
     
    162149?>
    163150                </select>
    164                 <?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
     151                <input type="submit" name="Submit" value="<?php esc_attr_e('Select') ?>" class="button" />
    165152        </form>
    166153</div>
     
    168155</div>
    169156        <div id="templateside">
     157
    170158<?php
    171159if ($allowed_files) :
    172160?>
    173161        <h3><?php _e('Templates'); ?></h3>
    174         <?php if ( $is_child_theme ) : ?>
    175         <p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), $themes[$theme]['Parent Theme'] ); ?></p>
    176         <?php endif; ?>
    177162        <ul>
    178163<?php
     
    180165        $template_dir = $themes[$theme]['Template Dir'];
    181166        foreach ( $themes[$theme]['Template Files'] as $template_file ) {
    182                 // Don't show parent templates.
    183                 if ( $is_child_theme && strpos( $template_file, trailingslashit( $template_dir ) ) === 0 )
    184                         continue;
    185 
    186167                $description = trim( get_file_description($template_file) );
    187168                $template_show = basename($template_file);
    188169                $filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description";
    189170                $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $filedesc;
    190                 $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
     171
     172                // If we have two files of the same name prefer the one in the Template Directory
     173                // This means that we display the correct files for child themes which overload Templates as well as Styles
     174                if ( array_key_exists($description, $template_mapping ) ) {
     175                        if ( false !== strpos( $template_file, $template_dir ) )  {
     176                                $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
     177                        }
     178                } else {
     179                        $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
     180                }
    191181        }
    192182        ksort( $template_mapping );
     
    202192        $stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
    203193        foreach ( $themes[$theme]['Stylesheet Files'] as $style_file ) {
    204                 // Don't show parent styles.
    205                 if ( $is_child_theme && strpos( $style_file, trailingslashit( $template_dir ) ) === 0 )
    206                         continue;
    207 
    208194                $description = trim( get_file_description($style_file) );
    209195                $style_show = basename($style_file);
     
    238224
    239225                <div>
    240                 <?php if ( is_child_theme() && ! $is_child_theme && $themes[$theme]['Template'] == get_option('template') ) : ?>
    241                         <p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
    242                         <?php _e( 'This is a file in your current parent theme.' ); ?></p>
    243                 <?php endif; ?>
    244 <?php
    245         if ( is_writeable( $file ) ) :
    246                 submit_button( __( 'Update File' ), 'primary', 'submit', true, array( 'tabindex' => '2' ) );
    247         else : ?>
     226<?php if ( is_writeable($file) ) : ?>
     227                        <p class="submit">
     228<?php
     229        echo "<input type='submit' name='submit' class='button-primary' value='" . esc_attr__('Update File') . "' tabindex='2' />";
     230?>
     231</p>
     232<?php else : ?>
    248233<p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
    249234<?php endif; ?>
     
    269254}
    270255
    271 include(ABSPATH . "wp-admin/admin-footer.php");
     256include("./admin-footer.php");
Note: See TracChangeset for help on using the changeset viewer.