bbp_get_forum_freshness_link

Returns link to the most recent activity inside a forum.

Description

bbp_get_forum_freshness_link( (int) $forum_id = 0 ); 

Returns a complete link with attributes and content.

Parameters (1)

0. $forum_id — Optional. (int)
Forum id

Usage

  1. if ( !function_exists( 'bbp_get_forum_freshness_link' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // Optional. Forum id 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_forum_freshness_link($forum_id); 
  9.  

Defined (1)

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

/includes/forums/template.php  
  1. function bbp_get_forum_freshness_link( $forum_id = 0 ) { 
  2. $forum_id = bbp_get_forum_id( $forum_id ); 
  3. $active_id = bbp_get_forum_last_active_id( $forum_id ); 
  4. $link_url = $title = ''; 
  5.  
  6. if ( empty( $active_id ) ) 
  7. $active_id = bbp_get_forum_last_reply_id( $forum_id ); 
  8.  
  9. if ( empty( $active_id ) ) 
  10. $active_id = bbp_get_forum_last_topic_id( $forum_id ); 
  11.  
  12. if ( bbp_is_topic( $active_id ) ) { 
  13. $link_url = bbp_get_forum_last_topic_permalink( $forum_id ); 
  14. $title = bbp_get_forum_last_topic_title( $forum_id ); 
  15. } elseif ( bbp_is_reply( $active_id ) ) { 
  16. $link_url = bbp_get_forum_last_reply_url( $forum_id ); 
  17. $title = bbp_get_forum_last_reply_title( $forum_id ); 
  18.  
  19. $time_since = bbp_get_forum_last_active_time( $forum_id ); 
  20.  
  21. if ( !empty( $time_since ) && !empty( $link_url ) ) 
  22. $anchor = '<a href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $time_since ) . '</a>'; 
  23. else 
  24. $anchor = esc_html__( 'No Topics', bbpress ); 
  25.  
  26. return apply_filters( 'bbp_get_forum_freshness_link', $anchor, $forum_id, $time_since, $link_url, $title, $active_id );