Ticket #14897: 14897.18.diff

File 14897.18.diff, 2.6 KB (added by PeteMall, 2 years ago)

Update and error messages.

  • wp-admin/network/site-themes.php

     
    4343        switch ( $action ) { 
    4444                case 'enable': 
    4545                        $theme = $_GET['theme']; 
     46                        $update = 'enabled'; 
    4647                        if ( !$allowed_themes ) 
    4748                                $allowed_themes = array( $theme => true ); 
    4849                        else 
     
    5051                        break; 
    5152                case 'disable': 
    5253                        $theme = $_GET['theme']; 
     54                        $update = 'disabled'; 
    5355                        if ( !$allowed_themes ) 
    5456                                $allowed_themes = array(); 
    5557                        else 
    5658                                unset( $allowed_themes[$theme] ); 
    5759                        break; 
    5860                case 'enable-selected': 
    59                         $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 
    60                         if ( empty($themes) ) { 
    61                                 restore_current_blog(); 
    62                                 wp_redirect( wp_get_referer() ); 
    63                                 exit; 
    64                         }                                                
    65                         foreach( (array) $themes as $theme ) 
    66                                 $allowed_themes[ $theme ] = true; 
     61                        if ( isset( $_POST['checked'] ) ) { 
     62                                $update = 'enable'; 
     63                                $themes = (array) $_POST['checked']; 
     64                                foreach( (array) $themes as $theme ) 
     65                                        $allowed_themes[ $theme ] = true; 
     66                        } else { 
     67                                $update = 'error'; 
     68                        } 
    6769                        break; 
    6870                case 'disable-selected': 
    69                         $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 
    70                         if ( empty($themes) ) { 
    71                                 restore_current_blog(); 
    72                                 wp_redirect( wp_get_referer() ); 
    73                                 exit; 
    74                         }                                                
    75                         foreach( (array) $themes as $theme ) 
    76                                 unset( $allowed_themes[ $theme ] ); 
     71                        if ( isset( $_POST['checked'] ) ) { 
     72                                $update = 'disable'; 
     73                                $themes = (array) $_POST['checked']; 
     74                                foreach( (array) $themes as $theme ) 
     75                                        unset( $allowed_themes[ $theme ] ); 
     76                        } else { 
     77                                $update = 'error'; 
     78                        } 
    7779                        break; 
    7880        } 
    7981         
    8082        update_option( 'allowedthemes', $allowed_themes ); 
    8183        restore_current_blog(); 
    8284         
    83         wp_redirect( wp_get_referer() ); // @todo add_query_arg for update message 
     85        wp_redirect( add_query_arg( 'update', $update, wp_get_referer() ) ); 
    8486        exit;    
    8587} 
    8688 
     
    110112        echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' .  esc_html( $tab['label'] ) . '</a>'; 
    111113} 
    112114?> 
    113 </h3> 
     115</h3><?php 
     116 
     117if ( isset( $_GET['update'] ) ) { 
     118        switch ( $_GET['update'] ) { 
     119        case 'enabled': 
     120                echo '<div id="message" class="updated"><p>' . __( 'Theme enabled.' ) . '</p></div>'; 
     121                break; 
     122        case 'disabled': 
     123                echo '<div id="message" class="updated"><p>' . __( 'Theme disabled.' ) . '</p></div>'; 
     124                break; 
     125        case 'error': 
     126                echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>'; 
     127                break; 
     128        } 
     129} ?> 
     130 
    114131<p><?php _e( 'Network enabled themes are not shown on this screen.' ) ?></p> 
    115132 
    116133<form method="get" action="">