WordPress.org

Make WordPress Core

Changeset 17130


Ignore:
Timestamp:
12/24/2010 05:41:36 PM (7 years ago)
Author:
ryan
Message:

MS themes fixes. Fix bulk actions when no items selected. Props SergeyBiryukov, nacin. fixes #15920

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r17129 r17130  
    7979
    8080        foreach ( (array) $themes['all'] as $key => $theme ) {
    81             $theme_key = esc_html( $theme['Stylesheet'] );
     81            $theme_key = $theme['Stylesheet'];
    8282
    8383            if ( isset( $allowed_themes [ $theme_key ] ) )  {
     
    277277        );
    278278
    279         $theme_key = esc_html( $theme['Stylesheet'] );
     279        $theme_key = $theme['Stylesheet'];
    280280
    281281        if ( empty( $theme['enabled'] ) )
     
    286286        if ( current_user_can('edit_themes') )
    287287            $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme['Name'] ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
    288            
    289         if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes )
     288
     289        if ( empty( $theme['enabled'] ) && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
    290290            $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&amp;checked[]=' . $theme_key . '&amp;theme_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
    291291
  • trunk/wp-admin/network/themes.php

    r17127 r17130  
    2929
    3030// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    31 $_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']);
     31$temp_args = array( 'enabled', 'disabled', 'deleted', 'error', 'enabled', 'disabled', 'deleted', 'error' );
     32$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
     33$referer = remove_query_arg( $temp_args, wp_get_referer() );
    3234
    3335if ( $action ) {
     
    3840            $allowed_themes[ $_GET['theme'] ] = true;
    3941            update_site_option( 'allowedthemes', $allowed_themes );
    40             wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
    41             exit;           
     42            wp_redirect( add_query_arg( 'enabled', '1', $referer ) );
     43            exit;
    4244            break;
    4345        case 'disable':
     
    4547            unset( $allowed_themes[ $_GET['theme'] ] );
    4648            update_site_option( 'allowedthemes', $allowed_themes );
    47             wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message
     49            wp_redirect( add_query_arg( 'disabled', '1', $referer ) );
    4850            exit;
    4951            break;
     
    5254            $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    5355            if ( empty($themes) ) {
    54                 wp_redirect( wp_get_referer() );
    55                 exit;
    56             }                       
     56                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
     57                exit;
     58            }
    5759            foreach( (array) $themes as $theme )
    5860                $allowed_themes[ $theme ] = true;
    5961            update_site_option( 'allowedthemes', $allowed_themes );
     62            wp_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
     63            exit;
    6064            break;
    6165        case 'disable-selected':
     
    6367            $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    6468            if ( empty($themes) ) {
    65                 wp_redirect( wp_get_referer() );
    66                 exit;
    67             }                       
     69                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
     70                exit;
     71            }
    6872            foreach( (array) $themes as $theme )
    6973                unset( $allowed_themes[ $theme ] );
    7074            update_site_option( 'allowedthemes', $allowed_themes );
     75            wp_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
     76            exit;
    7177            break;
    7278        case 'delete-selected':
     
    7682
    7783            $themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
     84
     85            if ( isset( $themes[ get_option( 'template' ) ] ) )
     86                unset( $themes[ get_option( 'template' ) ] );
     87            if ( isset( $themes[ get_option( 'stylesheet' ) ] ) )
     88                unset( $themes[ get_option( 'stylesheet' ) ] );
     89
    7890            if ( empty( $themes ) ) {
    79                 wp_redirect( wp_get_referer() );
     91                wp_redirect( add_query_arg( 'error', 'none', $referer ) );
    8092                exit;
    8193            }
     
    94106           
    95107            if ( empty( $themes ) ) {
    96                 wp_redirect( add_query_arg( 'error', 'main', wp_get_referer() ) );
     108                wp_redirect( add_query_arg( 'error', 'main', $referer ) );
    97109                exit;
    98110            }
     
    150162            foreach ( $themes as $theme )
    151163                $delete_result = delete_theme( $theme );
    152             wp_redirect( network_admin_url( 'themes.php?deleted=true' ) );
     164            wp_redirect( add_query_arg( 'deleted', count( $themes ), $referer ) );
    153165            exit;
    154166            break;
     
    175187require_once(ABSPATH . 'wp-admin/admin-header.php');
    176188
    177 if ( isset( $_GET['deleted'] ) ) : ?>
    178 <div class="updated"><p><?php _e('Theme deleted.') ?></p></div><?php
    179 elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) : ?>
    180 <div class="error"><p><?php _e( 'You cannot delete a theme while it is active on the main site.' ); ?></p></div><?php
    181 endif;
    182189?>
    183190
     
    189196</h2>
    190197
     198<?php
     199if ( isset( $_GET['enabled'] ) ) {
     200    $_GET['enabled'] = absint( $_GET['enabled'] );
     201    echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>';
     202} elseif ( isset( $_GET['disabled'] ) ) {
     203    $_GET['disabled'] = absint( $_GET['disabled'] );
     204    echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>';
     205} elseif ( isset( $_GET['deleted'] ) ) {
     206    $_GET['disabled'] = absint( $_GET['deleted'] );
     207    echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>';
     208} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
     209    echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
     210} elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) {
     211    echo '<div class="error"><p>' . __( 'You cannot delete a theme while it is active on the main site.' ) . '</p></div>';
     212}
     213
     214?>
     215
    191216<form method="get" action="">
    192217<?php $wp_list_table->search_box( __( 'Search Installed Themes' ), 'theme' ); ?>
Note: See TracChangeset for help on using the changeset viewer.