Make WordPress Core


Ignore:
Timestamp:
11/08/2010 09:52:54 PM (16 years ago)
Author:
ryan
Message:

site-themes.php cleanup. Props PeteMall. see #14897

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-themes-list-table.php

    r16241 r16242  
    88 */
    99class WP_MS_Themes_List_Table extends WP_List_Table {
     10       
     11        var $site_id;
     12        var $is_site_themes;
    1013
    1114        function WP_MS_Themes_List_Table() {
    … …  
    3841                }
    3942
    40                 if ( !current_user_can('manage_network_themes') )
    41                         wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
     43                if ( $this->is_site_themes && !current_user_can('manage_sites') )
     44                        wp_die( __( 'You do not have sufficient permissions to manage themes for this site.' ) );
     45                else if ( !$this->is_site_themes && !current_user_can('manage_network_themes') )
     46                        wp_die( __( 'You do not have sufficient permissions to manage network themes.' ) );
    4247        }
    4348
    … …  
    5560                );
    5661
    57                 $allowed_themes = get_site_allowed_themes();
     62                $site_allowed_themes = get_site_allowed_themes();
     63                if ( !$this->is_site_themes )
     64                        $allowed_themes = $site_allowed_themes;
     65                else
     66                        $allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id );
     67               
    5868                $current = get_site_transient( 'update_themes' );
    5969
    6070                foreach ( (array) $themes['all'] as $key => $theme ) {
    6171                        $theme_key = esc_html( $theme['Stylesheet'] );
     72
    6273                        if ( isset( $allowed_themes [ $theme_key ] ) )  {
    6374                                $themes['all'][$key]['enabled'] = true;
    … …  
    7081                        if ( isset( $current->response[ $theme['Template'] ] ) )
    7182                                $themes['upgrade'][$key] = $themes['all'][$key];
     83
     84                        if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) {
     85                                unset( $themes['all'][$key] );
     86                                unset( $themes['enabled'][$key] );
     87                                unset( $themes['disabled'][$key] );
     88                        }
    7289                }
    7390
    … …  
    189206                        }
    190207
     208                        if ( $this->is_site_themes )
     209                                $url = 'site-themes.php?id=' . $this->site_id;
     210                        else
     211                                $url = 'themes.php';
     212
    191213                        $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
    192                                 add_query_arg('theme_status', $type, 'themes.php'),
     214                                add_query_arg('theme_status', $type, $url),
    193215                                ( $type == $status ) ? ' class="current"' : '',
    194216                                sprintf( $text, number_format_i18n( $count ) )
    … …  
    204226                $actions = array();
    205227                if ( 'enabled' != $status )
    206                         $actions['network-enable-selected'] = __( 'Enable' );
     228                        $actions['enable-selected'] = __( 'Enable' );
    207229                if ( 'disabled' != $status )
    208                         $actions['network-disable-selected'] = __( 'Disable' );
     230                        $actions['disable-selected'] = __( 'Disable' );
    209231                if ( current_user_can( 'update_themes' ) )
    210232                        $actions['update-selected'] = __( 'Update' );
    … …  
    226248
    227249                $context = $status;
     250               
     251                if ( $this->is_site_themes )
     252                        $url = "site-themes.php?id={$this->site_id}&amp;";
     253                else
     254                        $url = 'themes.php?';
    228255
    229256                foreach ( $this->items as $key => $theme ) {
    230257                        // preorder
    231258                        $actions = array(
    232                                 'network_enable' => '',
    233                                 'network_disable' => '',
     259                                'enable' => '',
     260                                'disable' => '',
    234261                                'edit' => ''
    235262                        );
    … …  
    237264                        $theme_key = esc_html( $theme['Stylesheet'] );
    238265
    239                         if ( empty( $theme['enabled'] ) ) {
    240                                 if ( current_user_can( 'manage_network_themes' ) )
    241                                         $actions['network_enable'] = '<a href="' . wp_nonce_url('themes.php?action=network-enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme for all sites in this network') . '" class="edit">' . __('Enable') . '</a>';
    242                         } else {
    243                                 if ( current_user_can( 'manage_network_themes' ) )
    244                                         $actions['network_disable'] = '<a href="' . wp_nonce_url('themes.php?action=network-disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
    245                         }
     266                        if ( empty( $theme['enabled'] ) )
     267                                        $actions['enable'] = '<a href="' . wp_nonce_url($url . 'action=enable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'enable-theme_' . $theme_key) . '" title="' . __('Enable this theme') . '" class="edit">' . __('Enable') . '</a>';
     268                        else
     269                                        $actions['disable'] = '<a href="' . wp_nonce_url($url . 'action=disable&amp;theme=' . $theme_key . '&amp;paged=' . $page . '&amp;s=' . $s, 'disable-theme_' . $theme_key) . '" title="' . __('Disable this theme') . '">' . __('Disable') . '</a>';
    246270                       
    247271                        if ( current_user_can('edit_themes') )
Note: See TracChangeset for help on using the changeset viewer.