Changeset 35823

Show
Ignore:
Timestamp:
03/22/08 08:43:08 (4 months ago)
Author:
ear1grey
Message:

Improved action feedback (now uses an array of messages rather than individual echo statements).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • worst-offenders/trunk/functions.php

    r35682 r35823  
    119119      $count = get_current_count(); 
    120120       
     121      wo3_check_user_input(); 
     122       
    121123      if ( isset( $submenu['edit-comments.php'] )     ) 
    122124            add_submenu_page('edit-comments.php',     __($wo3_title),   __($wo3_title . "(" . $count . ")"),      1, __($wo3_title), 'wo3_list' ); 
     
    166168 
    167169function reset_current_count() { 
    168       global $keys
     170      global $keys, $wo3_title
    169171      wp_cache_delete("current_count", $wo3_title); 
    170       wp_cache_delete("current_ids", 'worstoffenders'); 
     172      wp_cache_delete("current_ids", $wo3_title); 
    171173} 
    172174 
     
    183185 
    184186function wo3_list()     { 
    185       global $wpdb,     $comment,   $wo3_title
     187      global $wpdb,     $comment,   $wo3_title, $wo3_feedback
    186188      css(); 
    187189      ?> 
     
    189191      <h2><?php   _e($wo3_title);   ?></h2> 
    190192      <?php 
    191       wo3_check_user_input(); 
     193      if (is_array($wo3_feedback)) { 
     194            foreach($wo3_feedback as $feedback) {  
     195                  echo $feedback; 
     196            } 
     197            $wo3_feedback = array(); 
     198      } 
    192199      wo3_tabs(); 
    193200      echo("</div>"); 
     
    224231 
    225232function wo3_check_user_input()     { 
    226       global $keys
     233      global $keys, $wo3_feedback
    227234      if ($_POST['act'] == 'delete') { 
    228235            if (!empty($_POST['worst'])) { 
     
    230237                  $deleted = do_delete($deletionList); 
    231238                  if ($deleted === false) { 
    232                         echo "<div class='updated'>DB     Error -     Failed to   delete - Boo!      Perhaps the DB   log   can   help!</div>"; 
     239                        $wo3_feedback[] = "<div class='updated'>DB    Error -     Failed to   delete - Boo!      Perhaps the DB   log   can   help!</div>"; 
    233240                  }     else { 
     241                        $wo3_feedback[] = "<div class='updated'>Congratulations, you just deleted <strong>$deleted</strong> spam comments!</div>"; 
    234242                        update_option( $keys['counter'], $deleted + get_option( $keys['counter'] ) ); 
    235243                        reset_current_count(); 
    236244                  } 
     245            } else { 
     246                  $wo3_feedback[] = "<div class='updated'>Nothing selected for deletion.</div>"; 
    237247            } 
    238248      }