bb_die

The BuddyPress bb die function.

Description

bb_die( $message, (string) $title = '', (int) $header = 0 ); 

Parameters (3)

0. $message
The message.
1. $title — Optional. (string) => ''
The title.
2. $header — Optional. (int)
The header.

Usage

  1. if ( !function_exists( 'bb_die' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-core.php'; 
  3.  
  4. // The message. 
  5. $message = null; 
  6.  
  7. // The title. 
  8. $title = ''; 
  9.  
  10. // The header. 
  11. $header = -1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_die($message, $title, $header); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-core.php  
  1. function bb_die( $message, $title = '', $header = 0 ) { 
  2. global $bb_locale; 
  3.  
  4. if ( $header && !headers_sent() ) 
  5. status_header( $header ); 
  6.  
  7. if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { 
  8. if ( empty( $title ) ) { 
  9. $error_data = $message->get_error_data(); 
  10. if ( is_array( $error_data ) && isset( $error_data['title'] ) ) 
  11. $title = $error_data['title']; 
  12. $errors = $message->get_error_messages(); 
  13. switch ( count( $errors ) ) : 
  14. case 0 : 
  15. $message = ''; 
  16. break; 
  17. case 1 : 
  18. $message = "<p>{$errors[0]}</p>"; 
  19. break; 
  20. default : 
  21. $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; 
  22. break; 
  23. endswitch; 
  24. } elseif ( is_string( $message ) ) { 
  25. $message = bb_autop( $message ); 
  26.  
  27. if ( empty($title) ) 
  28. $title = __('bbPress › Error'); 
  29.  
  30. bb_install_header( $title ); 
  31. ?> 
  32. <?php echo $message; ?> 
  33. <?php 
  34. if ($uri = bb_get_uri()) { 
  35. ?> 
  36. <p class="last"><?php printf( __('Back to <a href="%s">%s</a>.'), $uri, bb_get_option( 'name' ) ); ?></p> 
  37. <?php 
  38. die();