bb_cache_post_topics

The BuddyPress bb cache post topics function.

Description

bb_cache_post_topics( $posts ); 

Parameters (1)

0. $posts
The posts.

Usage

  1. if ( !function_exists( 'bb_cache_post_topics' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-posts.php'; 
  3.  
  4. // The posts. 
  5. $posts = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_cache_post_topics($posts); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-posts.php  
  1. function bb_cache_post_topics( $posts ) { 
  2. global $bbdb; 
  3.  
  4. if ( !$posts ) 
  5. return; 
  6.  
  7. $topic_ids = array(); 
  8. foreach ( $posts as $post ) 
  9. if ( false === wp_cache_get( $post->topic_id, 'bb_topic' ) ) 
  10. $topic_ids[] = (int) $post->topic_id; 
  11.  
  12. if ( !$topic_ids ) 
  13. return; 
  14.  
  15. sort( $topic_ids ); 
  16. $topic_ids = join(', ', $topic_ids); 
  17.  
  18. if ( $topics = $bbdb->get_results( "SELECT * FROM $bbdb->topics WHERE topic_id IN($topic_ids)" ) ) 
  19. bb_append_meta( $topics, 'topic' );