bbp_get_reply_excerpt

Return the excerpt of the reply.

Description

(string) bbp_get_reply_excerpt( (int) $reply_id = 0, (int) $length = 100 ); 

Returns (string)

Reply Excerpt

Parameters (2)

0. $reply_id — Optional. (int)
Reply id
1. $length — Optional. (int) => 100
Length of the excerpt. Defaults to 100 letters

Usage

  1. if ( !function_exists( 'bbp_get_reply_excerpt' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. Reply id 
  5. $reply_id = -1; 
  6.  
  7. // Optional. Length of the excerpt. Defaults to 100 
  8. // letters 
  9. $length = 100; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bbp_get_reply_excerpt($reply_id, $length); 
  13.  

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_excerpt( $reply_id = 0, $length = 100 ) { 
  2. $reply_id = bbp_get_reply_id( $reply_id ); 
  3. $length = (int) $length; 
  4. $excerpt = get_post_field( 'post_excerpt', $reply_id ); 
  5.  
  6. if ( empty( $excerpt ) ) { 
  7. $excerpt = bbp_get_reply_content( $reply_id ); 
  8.  
  9. $excerpt = trim ( strip_tags( $excerpt ) ); 
  10.  
  11. // Multibyte support 
  12. if ( function_exists( 'mb_strlen' ) ) { 
  13. $excerpt_length = mb_strlen( $excerpt ); 
  14. } else { 
  15. $excerpt_length = strlen( $excerpt ); 
  16.  
  17. if ( !empty( $length ) && ( $excerpt_length > $length ) ) { 
  18. $excerpt = substr( $excerpt, 0, $length - 1 ); 
  19. $excerpt .= '…'; 
  20.  
  21. return apply_filters( 'bbp_get_reply_excerpt', $excerpt, $reply_id, $length );