Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r15135 r17471  
    1010require_once('./admin.php');
    1111
     12if ( is_multisite() && ! is_network_admin() ) {
     13    wp_redirect( network_admin_url( 'theme-editor.php' ) );
     14    exit();
     15}
     16
    1217if ( !current_user_can('edit_themes') )
    1318    wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
     
    2227$help .= '<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>';
    2328$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>';
     29if ( is_network_admin() )
     30    $help .= '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>';
    2431$help .= '<p><strong>' . __('For more information:') . '</strong></p>';
    2532$help .= '<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>';
     
    4552    wp_die(__('The requested theme does not exist.'));
    4653
    47 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
    48 
    49 if (empty($file)) {
    50     $file = $allowed_files[0];
     54$allowed_files = array_merge( $themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files'] );
     55
     56if ( 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];
    5161} else {
    5262    $file = stripslashes($file);
     
    94104default:
    95105
    96     require_once('./admin-header.php');
     106    require_once(ABSPATH . 'wp-admin/admin-header.php');
    97107
    98108    update_recently_edited($file);
     
    101111        $error = 1;
    102112
     113    $content = '';
    103114    if ( !$error && filesize($file) > 0 ) {
    104115        $f = fopen($file, 'r');
     
    116127        }
    117128
    118         $content = htmlspecialchars( $content );
     129        $content = esc_textarea( $content );
    119130    }
    120131
     
    125136
    126137$description = get_file_description($file);
    127 $desc_header = ( $description != $file_show ) ? "<strong>$description</strong> (%s)" : "%s";
     138$desc_header = ( $description != $file_show ) ? "$description <span>($file_show)</span>" : $file_show;
     139
     140$is_child_theme = $themes[$theme]['Template'] != $themes[$theme]['Stylesheet'];
    128141?>
    129142<div class="wrap">
     
    133146<div class="fileedit-sub">
    134147<div class="alignleft">
    135 <big><?php echo sprintf($desc_header, $file_show); ?></big>
     148<h3><?php echo $themes[$theme]['Name'] . ': ' . $desc_header; ?></h3>
    136149</div>
    137150<div class="alignright">
     
    149162?>
    150163        </select>
    151         <input type="submit" name="Submit" value="<?php esc_attr_e('Select') ?>" class="button" />
     164        <?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
    152165    </form>
    153166</div>
     
    155168</div>
    156169    <div id="templateside">
    157 
    158170<?php
    159171if ($allowed_files) :
    160172?>
    161173    <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; ?>
    162177    <ul>
    163178<?php
     
    165180    $template_dir = $themes[$theme]['Template Dir'];
    166181    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
    167186        $description = trim( get_file_description($template_file) );
    168187        $template_show = basename($template_file);
    169188        $filedesc = ( $description != $template_file ) ? "$description<br /><span class='nonessential'>($template_show)</span>" : "$description";
    170189        $filedesc = ( $template_file == $file ) ? "<span class='highlight'>$description<br /><span class='nonessential'>($template_show)</span></span>" : $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         }
     190        $template_mapping[ $description ] = array( _get_template_edit_filename($template_file, $template_dir), $filedesc );
    181191    }
    182192    ksort( $template_mapping );
     
    192202    $stylesheet_dir = $themes[$theme]['Stylesheet Dir'];
    193203    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
    194208        $description = trim( get_file_description($style_file) );
    195209        $style_show = basename($style_file);
     
    224238
    225239        <div>
    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 : ?>
     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 : ?>
    233248<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>
    234249<?php endif; ?>
     
    254269}
    255270
    256 include("./admin-footer.php");
     271include(ABSPATH . "wp-admin/admin-footer.php");
Note: See TracChangeset for help on using the changeset viewer.