bbp_template_notices

Display possible errors & messages inside a template file.

Description

bbp_template_notices(); 

Usage

  1. if ( !function_exists( 'bbp_template_notices' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_template_notices(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/common/template.php  
  1. function bbp_template_notices() { 
  2.  
  3. // Bail if no notices or errors 
  4. if ( !bbp_has_errors() ) 
  5. return; 
  6.  
  7. // Define local variable(s) 
  8. $errors = $messages = array(); 
  9.  
  10. // Get bbPress 
  11. $bbp =bbpress); 
  12.  
  13. // Loop through notices 
  14. foreach ( $bbp->errors->get_error_codes() as $code ) { 
  15.  
  16. // Get notice severity 
  17. $severity = $bbp->errors->get_error_data( $code ); 
  18.  
  19. // Loop through notices and separate errors from messages 
  20. foreach ( $bbp->errors->get_error_messages( $code ) as $error ) { 
  21. if ( 'message' === $severity ) { 
  22. $messages[] = $error; 
  23. } else { 
  24. $errors[] = $error; 
  25.  
  26. // Display errors first... 
  27. if ( !empty( $errors ) ) : ?> 
  28.  
  29. <div class="bbp-template-notice error"> 
  30. <p> 
  31. <?php echo implode( "</p>\n<p>", $errors ); ?> 
  32. </p> 
  33. </div> 
  34.  
  35. <?php endif; 
  36.  
  37. // ...and messages last 
  38. if ( !empty( $messages ) ) : ?> 
  39.  
  40. <div class="bbp-template-notice"> 
  41. <p> 
  42. <?php echo implode( "</p>\n<p>", $messages ); ?> 
  43. </p> 
  44. </div> 
  45.  
  46. <?php endif;