bp_admin_tools_feedback

Assemble admin notices relating success/failure of repair processes.

Description

bp_admin_tools_feedback( (string) $message, (bool) $class = false ); 

Parameters (2)

0. $message (string)
Feedback message.
1. $class — Optional. (bool) => false
The class.

Usage

  1. if ( !function_exists( 'bp_admin_tools_feedback' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/admin/bp-core-admin-tools.php'; 
  3.  
  4. // Feedback message. 
  5. $message = ''; 
  6.  
  7. // The class. 
  8. $class = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_admin_tools_feedback($message, $class); 
  12.  

Defined (1)

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

/bp-core/admin/bp-core-admin-tools.php  
  1. function bp_admin_tools_feedback( $message, $class = false ) { 
  2. if ( is_string( $message ) ) { 
  3. $message = '<p>' . $message . '</p>'; 
  4. $class = $class ? $class : 'updated'; 
  5. } elseif ( is_wp_error( $message ) ) { 
  6. $errors = $message->get_error_messages(); 
  7.  
  8. switch ( count( $errors ) ) { 
  9. case 0: 
  10. return false; 
  11.  
  12. case 1: 
  13. $message = '<p>' . $errors[0] . '</p>'; 
  14. break; 
  15.  
  16. default: 
  17. $message = '<ul>' . "\n\t" . '<li>' . implode( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>'; 
  18. break; 
  19.  
  20. $class = $class ? $class : error; 
  21. } else { 
  22. return false; 
  23.  
  24. $message = '<div id="message" class="' . esc_attr( $class ) . '">' . $message . '</div>'; 
  25. $message = str_replace( "'", "\'", $message ); 
  26. $lambda = function() use ( $message ) { echo $message; }; 
  27.  
  28.  
  29. return $lambda;