bp_activity_embed_has_activity

Query for the activity item on the activity embed template.

Description

bp_activity_embed_has_activity( (int) $activity_id = 0 ); 

Basically a wrapper for , but allows us to use the activity loop without requerying for it again.

Parameters (1)

0. $activity_id — Optional. (int)
The activity id.

Usage

  1. if ( !function_exists( 'bp_activity_embed_has_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-embeds.php'; 
  3.  
  4. // The activity id. 
  5. $activity_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_embed_has_activity($activity_id); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-embeds.php  
  1. function bp_activity_embed_has_activity( $activity_id = 0 ) { 
  2. global $activities_template; 
  3.  
  4. if ( empty( $activity_id ) ) { 
  5. return false; 
  6.  
  7. if ( ! empty( $activities_template->activities ) ) { 
  8. $activity = (array) $activities_template->activities; 
  9. $activity = reset( $activity ); 
  10.  
  11. // No need to requery if we already got the embed activity 
  12. if ( (int) $activity_id === $activity->id ) { 
  13. return $activities_template->has_activities(); 
  14.  
  15. return bp_has_activities( array( 
  16. 'display_comments' => 'threaded',  
  17. 'show_hidden' => true,  
  18. 'include' => (int) $activity_id,  
  19. ) );