mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 23:27:39 +02:00
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.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
30a15b7c87
commit
f73524c272
@ -54,26 +54,18 @@ $theme = wp_get_theme( $stylesheet );
|
|||||||
if ( ! $theme->exists() )
|
if ( ! $theme->exists() )
|
||||||
wp_die( __( 'The requested theme does not exist.' ) );
|
wp_die( __( 'The requested theme does not exist.' ) );
|
||||||
|
|
||||||
|
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
|
||||||
|
wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
|
||||||
|
|
||||||
$allowed_files = $theme->get_files( 'php', 1 );
|
$allowed_files = $theme->get_files( 'php', 1 );
|
||||||
$has_templates = ! empty( $allowed_files );
|
$has_templates = ! empty( $allowed_files );
|
||||||
|
|
||||||
$style_files = $theme->get_files( 'css' );
|
$style_files = $theme->get_files( 'css' );
|
||||||
if ( isset( $style_files['style.css'] ) ) {
|
|
||||||
$allowed_files['style.css'] = $style_files['style.css'];
|
$allowed_files['style.css'] = $style_files['style.css'];
|
||||||
unset( $style_files['style.css'] );
|
|
||||||
} else {
|
|
||||||
$style_files['style.css'] = false;
|
|
||||||
}
|
|
||||||
$allowed_files += $style_files;
|
$allowed_files += $style_files;
|
||||||
|
|
||||||
if ( empty( $file ) ) {
|
if ( empty( $file ) ) {
|
||||||
if ( ! empty( $allowed_files['style.css'] ) ) {
|
|
||||||
$relative_file = 'style.css';
|
$relative_file = 'style.css';
|
||||||
$file = $allowed_files['style.css'];
|
$file = $allowed_files['style.css'];
|
||||||
} else {
|
|
||||||
$relative_file = key( $allowed_files );
|
|
||||||
$file = current( $allowed_files );
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$relative_file = urldecode( stripslashes( $file ) );
|
$relative_file = urldecode( stripslashes( $file ) );
|
||||||
$file = $theme->get_stylesheet_directory() . '/' . $relative_file;
|
$file = $theme->get_stylesheet_directory() . '/' . $relative_file;
|
||||||
@ -153,6 +145,9 @@ if ( $description != $file_show )
|
|||||||
<select name="theme" id="theme">
|
<select name="theme" id="theme">
|
||||||
<?php
|
<?php
|
||||||
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
|
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
|
||||||
|
if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() )
|
||||||
|
continue;
|
||||||
|
|
||||||
$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
|
$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
|
||||||
echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>';
|
echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>';
|
||||||
}
|
}
|
||||||
@ -165,23 +160,20 @@ foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_them
|
|||||||
</div>
|
</div>
|
||||||
<div id="templateside">
|
<div id="templateside">
|
||||||
<?php
|
<?php
|
||||||
if ( array_filter( $allowed_files ) ) :
|
if ( $allowed_files ) :
|
||||||
if ( $has_templates || $theme->is_child_theme() ) :
|
if ( $has_templates || $theme->is_child_theme() ) :
|
||||||
?>
|
?>
|
||||||
<h3><?php _e('Templates'); ?></h3>
|
<h3><?php _e('Templates'); ?></h3>
|
||||||
<?php if ( $theme->is_child_theme() ) : ?>
|
<?php if ( $theme->is_child_theme() ) : ?>
|
||||||
<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>
|
<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>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach ( $allowed_files as $filename => $absolute_filename ) :
|
foreach ( $allowed_files as $filename => $absolute_filename ) :
|
||||||
if ( 'style.css' == $filename ) {
|
if ( 'style.css' == $filename )
|
||||||
echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
|
echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
|
||||||
if ( ! $absolute_filename )
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_description = get_file_description( $filename );
|
$file_description = get_file_description( $filename );
|
||||||
if ( $file_description != basename( $filename ) )
|
if ( $file_description != basename( $filename ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user