bbp_admin_tools_feedback

Assemble the admin notices.

Description

(string) bbp_admin_tools_feedback( (string|WP_Error) $message, (bool) $class = false ); 

Returns (string)

The message HTML

Parameters (2)

0. $message (string|WP_Error)
The message.

Options

    ;        

    1. $class — Optional. (bool) => false
    A class to be added to the message div

    Usage

    1. if ( !function_exists( 'bbp_admin_tools_feedback' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/admin/tools.php'; 
    3.  
    4. // The message. 
    5. $message = null; 
    6.  
    7. // Optional. A class to be added to the message div 
    8. $class = false; 
    9.  
    10. // NOTICE! Understand what this does before running. 
    11. $result = bbp_admin_tools_feedback($message, $class); 
    12.  

    Defined (1)

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

    /includes/admin/tools.php  
    1. function bbp_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. break; 
    12.  
    13. case 1: 
    14. $message = '<p>' . $errors[0] . '</p>'; 
    15. break; 
    16.  
    17. default: 
    18. $message = '<ul>' . "\n\t" . '<li>' . implode( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>'; 
    19. break; 
    20.  
    21. $class = $class ? $class : error; 
    22. } else { 
    23. return false; 
    24.  
    25. $message = '<div id="message" class="' . esc_attr( $class ) . '">' . $message . '</div>'; 
    26. $message = str_replace( "'", "\'", $message ); 
    27. $lambda = create_function( '', "echo '$message';" ); 
    28.  
    29. add_action( 'admin_notices', $lambda ); 
    30.  
    31. return $lambda;