Show a proper error message on the dashboard when the current theme is broken.

Clean up Appearance -> Themes when we don't have enough information to show for a broken theme.

Clean up broken/ugly "alt" row styling when we are displaying broken themes.

props johnbillion for initial patch.
fixes #21670.

Built from https://develop.svn.wordpress.org/trunk@25666


git-svn-id: http://core.svn.wordpress.org/trunk@25582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-02 20:50:09 +00:00
parent 51ff617278
commit 7de2054ece
3 changed files with 14 additions and 5 deletions

View File

@ -366,7 +366,7 @@ function wp_dashboard_right_now() {
if ( $theme->errors() ) { if ( $theme->errors() ) {
if ( ! is_multisite() || is_super_admin() ) if ( ! is_multisite() || is_super_admin() )
echo '<span class="error-message">' . __('ERROR: The themes directory is either empty or doesn&#8217;t exist. Please check your installation.') . '</span>'; echo '<span class="error-message">' . sprintf( __( 'ERROR: %s' ), $theme->errors()->get_error_message() ) . '</span>';
} elseif ( ! empty($wp_registered_sidebars) ) { } elseif ( ! empty($wp_registered_sidebars) ) {
$sidebars_widgets = wp_get_sidebars_widgets(); $sidebars_widgets = wp_get_sidebars_widgets();
$num_widgets = 0; $num_widgets = 0;

View File

@ -139,6 +139,15 @@ $customize_title = sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->display('Na
<?php echo $ct->display('Name'); ?> <?php echo $ct->display('Name'); ?>
</h4> </h4>
<?php
if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
echo '<p class="error-message">' . sprintf( __( 'ERROR: %s' ), $ct->errors()->get_error_message() ) . '</p>';
}
// Certain error codes are less fatal than others. We can still display theme information in most cases.
if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
&& in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
<div> <div>
<ul class="theme-info"> <ul class="theme-info">
<li><?php printf( __('By %s'), $ct->display('Author') ); ?></li> <li><?php printf( __('By %s'), $ct->display('Author') ); ?></li>
@ -207,6 +216,8 @@ $customize_title = sprintf( __( 'Customize &#8220;%s&#8221;' ), $ct->display('Na
endif; // options || edit_theme_options endif; // options || edit_theme_options
?> ?>
<?php endif; // theme errors ?>
</div> </div>
<br class="clear" /> <br class="clear" />
@ -292,11 +303,9 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_
<th><?php _e('Description'); ?></th> <th><?php _e('Description'); ?></th>
</tr> </tr>
<?php <?php
$alt = '';
foreach ( $broken_themes as $broken_theme ) { foreach ( $broken_themes as $broken_theme ) {
$alt = ('class="alternate"' == $alt) ? '' : 'class="alternate"';
echo " echo "
<tr $alt> <tr>
<td>" . $broken_theme->get('Name') ."</td> <td>" . $broken_theme->get('Name') ."</td>
<td>" . $broken_theme->errors()->get_error_message() . "</td> <td>" . $broken_theme->errors()->get_error_message() . "</td>
</tr>"; </tr>";

View File

@ -206,7 +206,7 @@ final class WP_Theme implements ArrayAccess {
} elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) { } elseif ( ! file_exists( $this->theme_root . '/' . $theme_file ) ) {
$this->headers['Name'] = $this->stylesheet; $this->headers['Name'] = $this->stylesheet;
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) ) if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet ) )
$this->errors = new WP_Error( 'theme_not_found', __( 'The theme directory does not exist.' ) ); $this->errors = new WP_Error( 'theme_not_found', sprintf( __( 'The theme directory "%s" does not exist.' ), $this->stylesheet ) );
else else
$this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) ); $this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) );
$this->template = $this->stylesheet; $this->template = $this->stylesheet;