Themes: Improve error messages for broken themes.

Props mayukojpn for initial patch.
Fixes #35286.

git-svn-id: https://develop.svn.wordpress.org/trunk@36638 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-02-23 17:19:57 +00:00
parent fe824ee872
commit 9ac7cc3aa0
3 changed files with 10 additions and 3 deletions

View File

@ -287,7 +287,7 @@ if ( isset( $_GET['enabled'] ) ) {
$wp_list_table->views(); $wp_list_table->views();
if ( 'broken' == $status ) if ( 'broken' == $status )
echo '<p class="clear">' . __('The following themes are installed but incomplete. Themes must have a stylesheet and a template.') . '</p>'; echo '<p class="clear">' . __( 'The following themes are installed but incomplete.' ) . '</p>';
?> ?>
<form method="post"> <form method="post">

View File

@ -295,7 +295,7 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_
<div class="broken-themes"> <div class="broken-themes">
<h3><?php _e('Broken Themes'); ?></h3> <h3><?php _e('Broken Themes'); ?></h3>
<p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
<?php <?php
$can_delete = current_user_can( 'delete_themes' ); $can_delete = current_user_can( 'delete_themes' );

View File

@ -268,7 +268,14 @@ final class WP_Theme implements ArrayAccess {
if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) { if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
$this->template = $this->stylesheet; $this->template = $this->stylesheet;
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) { if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
$this->errors = new WP_Error( 'theme_no_index', __( 'Template is missing.' ) ); $error_message = sprintf(
/* translators: 1: index.php, 2: Codex URL, 3: style.css */
__( 'Template is missing. Standalone themes need to have a %1$s template file. <a href="%2$s">Child themes</a> need to have a Template header in the %3$s stylesheet.' ),
'<code>index.php</code>',
__( 'https://codex.wordpress.org/Child_Themes' ),
'<code>style.css</code>'
);
$this->errors = new WP_Error( 'theme_no_index', $error_message );
$this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) );
return; return;
} }