WordPress.org

Make WordPress Core

Changeset 20557


Ignore:
Timestamp:
04/21/2012 08:57:54 PM (9 years ago)
Author:
nacin
Message:

Don't allow themes without a style.css editor to be edited. These themes are too broken to be salvaged by the theme editor. see #20103.

File:
1 edited

Legend:

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

    r20379 r20557  
    5555    wp_die( __( 'The requested theme does not exist.' ) );
    5656
     57if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
     58    wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
     59
    5760$allowed_files = $theme->get_files( 'php', 1 );
    5861$has_templates = ! empty( $allowed_files );
    59 
    6062$style_files = $theme->get_files( 'css' );
    61 if ( isset( $style_files['style.css'] ) ) {
    62     $allowed_files['style.css'] = $style_files['style.css'];
    63     unset( $style_files['style.css'] );
    64 } else {
    65     $style_files['style.css'] = false;
    66 }
     63$allowed_files['style.css'] = $style_files['style.css'];
    6764$allowed_files += $style_files;
    6865
    6966if ( empty( $file ) ) {
    70     if ( ! empty( $allowed_files['style.css'] ) ) {
    71         $relative_file = 'style.css';
    72         $file = $allowed_files['style.css'];
    73     } else {
    74         $relative_file = key( $allowed_files );
    75         $file = current( $allowed_files );
    76     }
     67    $relative_file = 'style.css';
     68    $file = $allowed_files['style.css'];
    7769} else {
    7870    $relative_file = urldecode( stripslashes( $file ) );
     
    154146<?php
    155147foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
     148    if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() )
     149        continue;
     150
    156151    $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
    157152    echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>';
     
    166161    <div id="templateside">
    167162<?php
    168 if ( array_filter( $allowed_files ) ) :
     163if ( $allowed_files ) :
    169164    if ( $has_templates || $theme->is_child_theme() ) :
    170165?>
    171166    <h3><?php _e('Templates'); ?></h3>
    172167    <?php if ( $theme->is_child_theme() ) : ?>
    173     <p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), '<a href="' . self_admin_url('theme-editor.php?theme=' . $theme->get_template()) . '">' . $theme->parent()->display('Name') . '</a>' ); ?></p>
     168    <p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), '<a href="' . self_admin_url('theme-editor.php?theme=' . urlencode( $theme->get_template() ) ) . '">' . $theme->parent()->display('Name') . '</a>' ); ?></p>
    174169    <?php endif; ?>
    175170    <ul>
     
    178173
    179174    foreach ( $allowed_files as $filename => $absolute_filename ) :
    180         if ( 'style.css' == $filename ) {
     175        if ( 'style.css' == $filename )
    181176            echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
    182             if ( ! $absolute_filename )
    183                 continue;
    184         }
    185177
    186178        $file_description = get_file_description( $filename );
Note: See TracChangeset for help on using the changeset viewer.