Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

wordpress admin_notices (debugging)

By: a guest on Aug 30th, 2012  |  syntax: PHP  |  size: 0.55 KB  |  views: 155  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $bh_errorMessages=array();
  2.  
  3. function bh_save_details(){
  4.         global $post, $bh_errorMessages;
  5.  
  6.         $bh_errorMessages[]="test error";
  7.         $bh_errorMessages[]="another test error";
  8. }
  9.  
  10. function bh_printErrorMessages(){
  11.         global $bh_errorMessages;
  12.        
  13.         $output='';    
  14.        
  15.         if(!empty($bh_errorMessages)){
  16.                 $output='<div class="error">';
  17.                 foreach($bh_errorMessages as $msg){
  18.                         $output.='<p>'.$msg.'<p>';
  19.                 }
  20.                 $output.='</div>';
  21.         }
  22.                
  23.         echo $output;
  24. }
  25.  
  26.  
  27. add_action('admin_notices', 'bh_printErrorMessages');
  28.  
  29. add_action('save_post', 'bh_save_details');