blp_change_freshness_topic

The bbP last post blp change freshness topic function.

Description

blp_change_freshness_topic( $last_active, $topic_id ); 

Parameters (2)

0. $last_active
The last active.
1. $topic_id
The topic id.

Usage

  1. if ( !function_exists( 'blp_change_freshness_topic' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbp-last-post/includes/functions.php'; 
  3.  
  4. // The last active. 
  5. $last_active = null; 
  6.  
  7. // The topic id. 
  8. $topic_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = blp_change_freshness_topic($last_active, $topic_id); 
  12.  

Defined (1)

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

/includes/functions.php  
  1. function blp_change_freshness_topic ($last_active, $topic_id) { 
  2.  
  3. $topic_id = bbp_get_topic_id( $topic_id ); 
  4.  
  5. // Try to get the most accurate freshness time possible 
  6. $last_active = get_post_meta( $topic_id, '_bbp_last_active_time', true ); 
  7. if ( empty( $last_active ) ) { 
  8. $reply_id = bbp_get_topic_last_reply_id( $topic_id ); 
  9. if ( !empty( $reply_id ) ) { 
  10. $last_active = get_post_field( 'post_date', $reply_id ); 
  11. } else { 
  12. $last_active = get_post_field( 'post_date', $topic_id ); 
  13.  
  14.  
  15. $last_active = bbp_convert_date( $last_active ) ; 
  16. $date_format = get_option( 'date_format' ); 
  17. $time_format = get_option( 'time_format' ); 
  18. $date= date_i18n( "{$date_format}", $last_active ); 
  19. $time=date_i18n( "{$time_format}", $last_active ); 
  20. $active_time = sprintf( _x( '%1$s at %2$s', 'date at time', 'bbp-last-post' ), $date, $time );  
  21. return apply_filters ('blp_change_freshness_topic' , $active_time) ;