Make WordPress Core

Changeset 17137


Ignore:
Timestamp:
12/25/2010 08:19:29 AM (14 years ago)
Author:
westi
Message:

Improved messaging for theme enabled/disabled on a per-site bases. Fixes #15920 props PeteMall

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/site-themes.php

    r17134 r17137  
    4040
    4141// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    42 $_SERVER['REQUEST_URI'] = remove_query_arg(array('enable', 'disable', 'enable-selected', 'disable-selected'), $_SERVER['REQUEST_URI']);
     42$temp_args = array( 'enabled', 'disabled', 'deleted', 'error', 'enabled', 'disabled', 'deleted', 'error' );
     43$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
     44$referer = remove_query_arg( $temp_args, wp_get_referer() );
    4345
    4446$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
     
    6365            check_admin_referer( 'enable-theme_' . $_GET['theme'] );
    6466            $theme = $_GET['theme'];
    65             $update = 'enabled';
     67            $action = 'enabled';
     68            $n = 1;
    6669            if ( !$allowed_themes )
    6770                $allowed_themes = array( $theme => true );
     
    7275            check_admin_referer( 'disable-theme_' . $_GET['theme'] );
    7376            $theme = $_GET['theme'];
    74             $update = 'disabled';
     77            $action = 'disabled';
     78            $n = 1;         
    7579            if ( !$allowed_themes )
    7680                $allowed_themes = array();
     
    8185            check_admin_referer( 'bulk-themes' );
    8286            if ( isset( $_POST['checked'] ) ) {
    83                 $update = 'enable';
    8487                $themes = (array) $_POST['checked'];
     88                $action = 'enabled';
     89                $n = count( $themes );
    8590                foreach( (array) $themes as $theme )
    8691                    $allowed_themes[ $theme ] = true;
    8792            } else {
    88                 $update = 'error';
     93                $action = 'error';
     94                $n = 'none';
    8995            }
    9096            break;
     
    9298            check_admin_referer( 'bulk-themes' );
    9399            if ( isset( $_POST['checked'] ) ) {
    94                 $update = 'disable';
    95100                $themes = (array) $_POST['checked'];
     101                $action = 'disabled';
     102                $n = count( $themes );
    96103                foreach( (array) $themes as $theme )
    97104                    unset( $allowed_themes[ $theme ] );
    98105            } else {
    99                 $update = 'error';
     106                $action = 'error';
     107                $n = 'none';
    100108            }
    101109            break;
     
    105113    restore_current_blog();
    106114   
    107     wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) );
     115    wp_redirect( add_query_arg( $action, $n, $referer ) );
    108116    exit;   
    109117}
    110118
    111119if ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
    112     wp_redirect( wp_get_referer() );
     120    wp_redirect( $referer );
    113121    exit();
    114122}
     
    141149</h3><?php
    142150
    143 if ( isset( $_GET['update'] ) ) {
    144     switch ( $_GET['update'] ) {
    145     case 'enabled':
    146         echo '<div id="message" class="updated"><p>' . __( 'Theme enabled.' ) . '</p></div>';
    147         break;
    148     case 'disabled':
    149         echo '<div id="message" class="updated"><p>' . __( 'Theme disabled.' ) . '</p></div>';
    150         break;
    151     case 'error':
    152         echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
    153         break;
    154     }
     151if ( isset( $_GET['enabled'] ) ) {
     152    $_GET['enabled'] = absint( $_GET['enabled'] );
     153    echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>';
     154} elseif ( isset( $_GET['disabled'] ) ) {
     155    $_GET['disabled'] = absint( $_GET['disabled'] );
     156    echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>';
     157} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
     158    echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
    155159} ?>
    156160
Note: See TracChangeset for help on using the changeset viewer.