In multisite, list broken themes on network/themes.php instead of on individual Manage Themes pages. see #20103.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20151 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-03-08 07:32:42 +00:00
parent 62cfbb074c
commit 7bac1174bf
3 changed files with 20 additions and 11 deletions

View File

@ -16,7 +16,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
global $status, $page; global $status, $page;
$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search' ) ) ) if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
$status = 'all'; $status = 'all';
$page = $this->get_pagenum(); $page = $this->get_pagenum();
@ -59,7 +59,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
'search' => array(), 'search' => array(),
'enabled' => array(), 'enabled' => array(),
'disabled' => array(), 'disabled' => array(),
'upgrade' => array() 'upgrade' => array(),
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
); );
if ( $this->is_site_themes ) { if ( $this->is_site_themes ) {
@ -70,7 +71,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$allowed_where = 'network'; $allowed_where = 'network';
} }
$current = current_user_can( 'update_themes' ) && ! $this->is_site_themes && get_site_transient( 'update_themes' ); $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && get_site_transient( 'update_themes' );
foreach ( (array) $themes['all'] as $key => $theme ) { foreach ( (array) $themes['all'] as $key => $theme ) {
if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {
@ -81,7 +82,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
$themes[ $filter ][ $key ] = $themes['all'][ $key ]; $themes[ $filter ][ $key ] = $themes['all'][ $key ];
if ( $current && isset( $current->response[ $key ] ) ) if ( $maybe_update && isset( $current->response[ $key ] ) )
$themes['upgrade'][ $key ] = $themes['all'][ $key ]; $themes['upgrade'][ $key ] = $themes['all'][ $key ];
} }
@ -206,6 +207,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
case 'upgrade': case 'upgrade':
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count ); $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
break; break;
case 'broken' :
$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
break;
} }
if ( $this->is_site_themes ) if ( $this->is_site_themes )
@ -297,8 +301,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$checkbox_id = "checkbox_" . md5( $theme->get('Name') ); $checkbox_id = "checkbox_" . md5( $theme->get('Name') );
$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>"; $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
$description = '<p>' . $theme->display( 'Description' ) . '</p>';
$id = sanitize_html_class( $theme->get_stylesheet() ); $id = sanitize_html_class( $theme->get_stylesheet() );
echo "<tr id='$id' class='$class'>"; echo "<tr id='$id' class='$class'>";
@ -320,8 +322,10 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
echo "</td>"; echo "</td>";
break; break;
case 'description': case 'description':
echo "<td class='column-description desc'$style> echo "<td class='column-description desc'$style>";
<div class='theme-description'>" . $theme->display( 'Description' ) . "</div> if ( $theme->errors() )
echo '<p><strong>' . $theme->errors()->get_error_message() . '</strong></p>';
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
<div class='$class second theme-version-author-uri'>"; <div class='$class second theme-version-author-uri'>";
$theme_meta = array(); $theme_meta = array();

View File

@ -40,7 +40,7 @@ if ( $action ) {
check_admin_referer('enable-theme_' . $_GET['theme']); check_admin_referer('enable-theme_' . $_GET['theme']);
$allowed_themes[ $_GET['theme'] ] = true; $allowed_themes[ $_GET['theme'] ] = true;
update_site_option( 'allowedthemes', $allowed_themes ); update_site_option( 'allowedthemes', $allowed_themes );
wp_redirect( network_admin_url( 'themes.php?enabled=1' ) ); wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
exit; exit;
break; break;
case 'disable': case 'disable':
@ -244,7 +244,12 @@ if ( isset( $_GET['enabled'] ) ) {
<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?> <?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
</form> </form>
<?php $wp_list_table->views(); ?> <?php
$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>';
?>
<form method="post" action=""> <form method="post" action="">
<input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" /> <input type="hidden" name="theme_status" value="<?php echo esc_attr($status) ?>" />

View File

@ -214,7 +214,7 @@ if ( ! current_user_can( 'switch_themes' ) ) {
<?php <?php
// List broken themes, if any. // List broken themes, if any.
if ( current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) { if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
?> ?>
<h3><?php _e('Broken Themes'); ?></h3> <h3><?php _e('Broken Themes'); ?></h3>