Themes: Improve error messages for broken themes.

Props mayukojpn for initial patch.
Fixes #35286.
Built from https://develop.svn.wordpress.org/trunk@36638


git-svn-id: http://core.svn.wordpress.org/trunk@36605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-02-23 17:20:27 +00:00
parent 0c242d0666
commit 81e9462ca3
4 changed files with 11 additions and 4 deletions

View File

@ -287,7 +287,7 @@ if ( isset( $_GET['enabled'] ) ) {
$wp_list_table->views();
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">

View File

@ -295,7 +295,7 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_
<div class="broken-themes">
<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
$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'] ) ) {
$this->template = $this->stylesheet;
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 ) );
return;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36637';
$wp_version = '4.5-alpha-36638';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.