bp_blogs_register_post_tracking_args

Set up the tracking arguments for the 'post' post type.

Description

(object) bp_blogs_register_post_tracking_args( (constant) $params = null, (int) $post_type = 0 ); 

Returns (object)

Parameters (2)

0. $params — Optional. (constant) => null
Tracking arguments.
1. $post_type — Optional. (int)
Post type to track.

Usage

  1. if ( !function_exists( 'bp_blogs_register_post_tracking_args' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-activity.php'; 
  3.  
  4. // Tracking arguments. 
  5. $params = null; 
  6.  
  7. // Post type to track. 
  8. $post_type = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_blogs_register_post_tracking_args($params, $post_type); 
  12.  

Defined (1)

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

/bp-blogs/bp-blogs-activity.php  
  1. function bp_blogs_register_post_tracking_args( $params = null, $post_type = 0 ) { 
  2.  
  3. /** 
  4. * Filters the post types to track for the Blogs component. 
  5. * @since 1.5.0 
  6. * @deprecated 2.3.0 
  7. * Make sure plugins still using 'bp_blogs_record_post_post_types' 
  8. * to track their post types will generate new_blog_post activities 
  9. * See https://buddypress.trac.wordpress.org/ticket/6306 
  10. * @param array $value Array of post types to track. 
  11. */ 
  12. $post_types = apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) ); 
  13. $post_types_array = array_flip( $post_types ); 
  14.  
  15. if ( ! isset( $post_types_array[ $post_type ] ) ) { 
  16. return $params; 
  17.  
  18. // Set specific params for the 'post' post type. 
  19. $params->component_id =buddypress)->blogs->id; 
  20. $params->action_id = 'new_blog_post'; 
  21. $params->admin_filter = __( 'New post published', buddypress ); 
  22. $params->format_callback = 'bp_blogs_format_activity_action_new_blog_post'; 
  23. $params->front_filter = __( 'Posts', buddypress ); 
  24. $params->contexts = array( 'activity', 'member' ); 
  25. $params->position = 5; 
  26.  
  27. if ( post_type_supports( $post_type, 'comments' ) ) { 
  28. $params->comment_action_id = 'new_blog_comment'; 
  29.  
  30. /** 
  31. * Filters the post types to track for the Blogs component. 
  32. * @since 1.5.0 
  33. * @deprecated 2.5.0 
  34. * Make sure plugins still using 'bp_blogs_record_comment_post_types' 
  35. * to track comment about their post types will generate new_blog_comment activities 
  36. * See https://buddypress.trac.wordpress.org/ticket/6306 
  37. * @param array $value Array of post types to track. 
  38. */ 
  39. $comment_post_types = apply_filters( 'bp_blogs_record_comment_post_types', array( 'post' ) ); 
  40. $comment_post_types_array = array_flip( $comment_post_types ); 
  41.  
  42. if ( isset( $comment_post_types_array[ $post_type ] ) ) { 
  43. $params->comments_tracking = new stdClass(); 
  44. $params->comments_tracking->component_id =buddypress)->blogs->id; 
  45. $params->comments_tracking->action_id = 'new_blog_comment'; 
  46. $params->comments_tracking->admin_filter = __( 'New post comment posted', buddypress ); 
  47. $params->comments_tracking->format_callback = 'bp_blogs_format_activity_action_new_blog_comment'; 
  48. $params->comments_tracking->front_filter = __( 'Comments', buddypress ); 
  49. $params->comments_tracking->contexts = array( 'activity', 'member' ); 
  50. $params->comments_tracking->position = 10; 
  51.  
  52. return $params;