Index: /trunk/wp-admin/includes/class-wp-ms-themes-list-table.php =================================================================== --- /trunk/wp-admin/includes/class-wp-ms-themes-list-table.php (revision 16241) +++ /trunk/wp-admin/includes/class-wp-ms-themes-list-table.php (revision 16242) @@ -8,4 +8,7 @@ */ class WP_MS_Themes_List_Table extends WP_List_Table { + + var $site_id; + var $is_site_themes; function WP_MS_Themes_List_Table() { @@ -38,6 +41,8 @@ } - if ( !current_user_can('manage_network_themes') ) - wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) ); + if ( $this->is_site_themes && !current_user_can('manage_sites') ) + wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) ); + else if ( !$this->is_site_themes && !current_user_can('manage_network_themes') ) + wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) ); } @@ -55,9 +60,15 @@ ); - $allowed_themes = get_site_allowed_themes(); + $site_allowed_themes = get_site_allowed_themes(); + if ( !$this->is_site_themes ) + $allowed_themes = $site_allowed_themes; + else + $allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id ); + $current = get_site_transient( 'update_themes' ); foreach ( (array) $themes['all'] as $key => $theme ) { $theme_key = esc_html( $theme['Stylesheet'] ); + if ( isset( $allowed_themes [ $theme_key ] ) ) { $themes['all'][$key]['enabled'] = true; @@ -70,4 +81,10 @@ if ( isset( $current->response[ $theme['Template'] ] ) ) $themes['upgrade'][$key] = $themes['all'][$key]; + + if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) { + unset( $themes['all'][$key] ); + unset( $themes['enabled'][$key] ); + unset( $themes['disabled'][$key] ); + } } @@ -189,6 +206,11 @@ } + if ( $this->is_site_themes ) + $url = 'site-themes.php?id=' . $this->site_id; + else + $url = 'themes.php'; + $status_links[$type] = sprintf( "%s", - add_query_arg('theme_status', $type, 'themes.php'), + add_query_arg('theme_status', $type, $url), ( $type == $status ) ? ' class="current"' : '', sprintf( $text, number_format_i18n( $count ) ) @@ -204,7 +226,7 @@ $actions = array(); if ( 'enabled' != $status ) - $actions['network-enable-selected'] = __( 'Enable' ); + $actions['enable-selected'] = __( 'Enable' ); if ( 'disabled' != $status ) - $actions['network-disable-selected'] = __( 'Disable' ); + $actions['disable-selected'] = __( 'Disable' ); if ( current_user_can( 'update_themes' ) ) $actions['update-selected'] = __( 'Update' ); @@ -226,10 +248,15 @@ $context = $status; + + if ( $this->is_site_themes ) + $url = "site-themes.php?id={$this->site_id}&"; + else + $url = 'themes.php?'; foreach ( $this->items as $key => $theme ) { // preorder $actions = array( - 'network_enable' => '', - 'network_disable' => '', + 'enable' => '', + 'disable' => '', 'edit' => '' ); @@ -237,11 +264,8 @@ $theme_key = esc_html( $theme['Stylesheet'] ); - if ( empty( $theme['enabled'] ) ) { - if ( current_user_can( 'manage_network_themes' ) ) - $actions['network_enable'] = '' . __('Enable') . ''; - } else { - if ( current_user_can( 'manage_network_themes' ) ) - $actions['network_disable'] = '' . __('Disable') . ''; - } + if ( empty( $theme['enabled'] ) ) + $actions['enable'] = '' . __('Enable') . ''; + else + $actions['disable'] = '' . __('Disable') . ''; if ( current_user_can('edit_themes') ) Index: /trunk/wp-admin/network/site-themes.php =================================================================== --- /trunk/wp-admin/network/site-themes.php (revision 16241) +++ /trunk/wp-admin/network/site-themes.php (revision 16242) @@ -1,20 +1,22 @@ check_permissions(); -if ( ! current_user_can('manage_sites') ) - wp_die(__('You do not have sufficient permissions to edit this site.')); +$action = $wp_list_table->current_action(); + +$s = isset($_REQUEST['s']) ? $_REQUEST['s'] : ''; + +// Clean up request URI from temporary args for screen options/paging uri's to work as expected. +$_SERVER['REQUEST_URI'] = remove_query_arg(array('network-enable', 'network-disable', 'network-enable-selected', 'network-disable-selected'), $_SERVER['REQUEST_URI']); $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; @@ -22,4 +24,8 @@ if ( ! $id ) wp_die( __('Invalid site ID.') ); + +$wp_list_table->site_id = $id; +$wp_list_table->is_site_themes = true; +$wp_list_table->prepare_items(); $details = get_blog_details( $id ); @@ -29,26 +35,50 @@ $is_main_site = is_main_site( $id ); -if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { - check_admin_referer( 'edit-site' ); +if ( $action ) { + switch_to_blog( $id ); + $allowed_themes = get_option( 'allowedthemes' ); - switch_to_blog( $id ); - - $allowedthemes = array(); - if ( isset($_POST['theme']) && is_array( $_POST['theme'] ) ) { - foreach ( $_POST['theme'] as $theme => $val ) { - if ( 'on' == $val ) - $allowedthemes[$theme] = true; - } + switch ( $action ) { + case 'enable': + $theme = $_GET['theme']; + if ( !$allowed_themes ) + $allowed_themes = array( $theme => true ); + else + $allowed_themes[$theme] = true; + break; + case 'disable': + $theme = $_GET['theme']; + if ( !$allowed_themes ) + $allowed_themes = array(); + else + unset( $allowed_themes[$theme] ); + break; + case 'enable-selected': + $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); + if ( empty($themes) ) { + restore_current_blog(); + wp_redirect( wp_get_referer() ); + exit; + } + foreach( (array) $themes as $theme ) + $allowed_themes[ $theme ] = true; + break; + case 'disable-selected': + $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); + if ( empty($themes) ) { + restore_current_blog(); + wp_redirect( wp_get_referer() ); + exit; + } + foreach( (array) $themes as $theme ) + unset( $allowed_themes[ $theme ] ); + break; } - update_option( 'allowedthemes', $allowedthemes ); - + + update_option( 'allowedthemes', $allowed_themes ); restore_current_blog(); - wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-themes.php') ); -} - -if ( isset($_GET['update']) ) { - $messages = array(); - if ( 'updated' == $_GET['update'] ) - $messages[] = __('Site users updated.'); + + wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message + exit; } @@ -59,4 +89,9 @@ require('../admin-header.php'); +add_thickbox(); + +add_screen_option( 'per_page', array('label' => _x( 'Themes', 'themes per page (screen options)' ), 'default' => 999) ); + +require_once(ABSPATH . 'wp-admin/admin-header.php'); ?> @@ -74,47 +109,21 @@ ?> +
' . $msg . '
'; -} ?> +} + +$wp_list_table->views(); ?> + - Index: /trunk/wp-admin/network/themes.php =================================================================== --- /trunk/wp-admin/network/themes.php (revision 16241) +++ /trunk/wp-admin/network/themes.php (revision 16242) @@ -18,10 +18,10 @@ // Clean up request URI from temporary args for screen options/paging uri's to work as expected. -$_SERVER['REQUEST_URI'] = remove_query_arg(array('network-enable', 'network-disable', 'network-enable-selected', 'network-disable-selected'), $_SERVER['REQUEST_URI']); +$_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']); if ( $action ) { $allowed_themes = get_site_option( 'allowedthemes' ); switch ( $action ) { - case 'network-enable': + case 'enable': $allowed_themes[ $_GET['theme'] ] = true; update_site_option( 'allowedthemes', $allowed_themes ); @@ -29,5 +29,5 @@ exit; break; - case 'network-disable': + case 'disable': unset( $allowed_themes[ $_GET['theme'] ] ); update_site_option( 'allowedthemes', $allowed_themes ); @@ -35,5 +35,5 @@ exit; break; - case 'network-enable-selected': + case 'enable-selected': $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); if ( empty($themes) ) { @@ -45,5 +45,5 @@ update_site_option( 'allowedthemes', $allowed_themes ); break; - case 'network-disable-selected': + case 'disable-selected': $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); if ( empty($themes) ) { @@ -82,5 +82,4 @@