bp_activity_format_activity_action_custom_post_type_post

Format activity action strings for custom post types.

Description

(string) bp_activity_format_activity_action_custom_post_type_post( (string) $action, (object) $activity ); 

Returns (string)

$action

Parameters (2)

0. $action (string)
Static activity action.
1. $activity (object)
Activity data object.

Usage

  1. if ( !function_exists( 'bp_activity_format_activity_action_custom_post_type_post' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // Static activity action. 
  5. $action = ''; 
  6.  
  7. // Activity data object. 
  8. $activity = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_activity_format_activity_action_custom_post_type_post($action, $activity); 
  12.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) { 
  2. $bp =buddypress); 
  3.  
  4. // Fetch all the tracked post types once. 
  5. if ( empty( $bp->activity->track ) ) { 
  6. $bp->activity->track = bp_activity_get_post_types_tracking_args(); 
  7.  
  8. if ( empty( $activity->type ) || empty( $bp->activity->track[ $activity->type ] ) ) { 
  9. return $action; 
  10.  
  11. $user_link = bp_core_get_userlink( $activity->user_id ); 
  12. $blog_url = get_home_url( $activity->item_id ); 
  13.  
  14. if ( empty( $activity->post_url ) ) { 
  15. $post_url = add_query_arg( 'p', $activity->secondary_item_id, trailingslashit( $blog_url ) ); 
  16. } else { 
  17. $post_url = $activity->post_url; 
  18.  
  19. if ( is_multisite() ) { 
  20. $blog_link = '<a href="' . esc_url( $blog_url ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>'; 
  21.  
  22. if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action_ms ) ) { 
  23. $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action_ms, $user_link, $post_url, $blog_link ); 
  24. } else { 
  25. $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>, on the site %3$s', 'Activity Custom Post Type post action', buddypress ), $user_link, esc_url( $post_url ), $blog_link ); 
  26. } else { 
  27. if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action ) ) { 
  28. $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action, $user_link, $post_url ); 
  29. } else { 
  30. $action = sprintf( _x( '%1$s wrote a new <a href="%2$s">item</a>', 'Activity Custom Post Type post action', buddypress ), $user_link, esc_url( $post_url ) ); 
  31.  
  32. /** 
  33. * Filters the formatted custom post type activity post action string. 
  34. * @since 2.2.0 
  35. * @param string $action Activity action string value. 
  36. * @param BP_Activity_Activity $activity Activity item object. 
  37. */