bp_activity_get_post_type_tracking_args

Get tracking arguments for a specific post type.

Description

(object) bp_activity_get_post_type_tracking_args( (string) $post_type ); 

Returns (object)

The tracking arguments of the post type.

Parameters (1)

0. $post_type (string)
Name of the post type.

Usage

  1. if ( !function_exists( 'bp_activity_get_post_type_tracking_args' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // Name of the post type. 
  5. $post_type = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_get_post_type_tracking_args($post_type); 
  9.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_get_post_type_tracking_args( $post_type ) { 
  2. if ( ! post_type_supports( $post_type, 'buddypress-activity' ) ) { 
  3. return false; 
  4.  
  5. $post_type_object = get_post_type_object( $post_type ); 
  6. $post_type_support_comments = post_type_supports( $post_type, 'comments' ); 
  7.  
  8. $post_type_activity = array( 
  9. 'component_id' =>buddypress)->activity->id,  
  10. 'action_id' => 'new_' . $post_type,  
  11. 'front_filter' => $post_type_object->labels->name,  
  12. 'contexts' => array( 'activity' ),  
  13. 'position' => 0,  
  14. 'singular' => strtolower( $post_type_object->labels->singular_name ),  
  15. 'activity_comment' => ! $post_type_support_comments,  
  16. 'comment_action_id' => false,  
  17. ); 
  18.  
  19. if ( ! empty( $post_type_object->bp_activity ) ) { 
  20. $post_type_activity = bp_parse_args( (array) $post_type_object->bp_activity, $post_type_activity, $post_type . '_tracking_args' ); 
  21.  
  22. $post_type_activity = (object) $post_type_activity; 
  23.  
  24. // Try to get the admin filter from the post type labels. 
  25. if ( ! empty( $post_type_object->labels->bp_activity_admin_filter ) ) { 
  26. $post_type_activity->admin_filter = $post_type_object->labels->bp_activity_admin_filter; 
  27.  
  28. // Fall back to a generic name. 
  29. } else { 
  30. $post_type_activity->admin_filter = _x( 'New item published', 'Post Type generic activity post admin filter', buddypress ); 
  31.  
  32. // Check for the front filter in the post type labels. 
  33. if ( ! empty( $post_type_object->labels->bp_activity_front_filter ) ) { 
  34. $post_type_activity->front_filter = $post_type_object->labels->bp_activity_front_filter; 
  35.  
  36. // Try to get the action for new post type action on non-multisite installations. 
  37. if ( ! empty( $post_type_object->labels->bp_activity_new_post ) ) { 
  38. $post_type_activity->new_post_type_action = $post_type_object->labels->bp_activity_new_post; 
  39.  
  40. // Try to get the action for new post type action on multisite installations. 
  41. if ( ! empty( $post_type_object->labels->bp_activity_new_post_ms ) ) { 
  42. $post_type_activity->new_post_type_action_ms = $post_type_object->labels->bp_activity_new_post_ms; 
  43.  
  44. // If the post type supports comments and has a comment action id, build the comments tracking args 
  45. if ( $post_type_support_comments && ! empty( $post_type_activity->comment_action_id ) ) { 
  46. // Init a new container for the activity type for comments 
  47. $post_type_activity->comments_tracking = new stdClass(); 
  48.  
  49. // Build the activity type for comments 
  50. $post_type_activity->comments_tracking->component_id = $post_type_activity->component_id; 
  51. $post_type_activity->comments_tracking->action_id = $post_type_activity->comment_action_id; 
  52.  
  53. // Try to get the comments admin filter from the post type labels. 
  54. if ( ! empty( $post_type_object->labels->bp_activity_comments_admin_filter ) ) { 
  55. $post_type_activity->comments_tracking->admin_filter = $post_type_object->labels->bp_activity_comments_admin_filter; 
  56.  
  57. // Fall back to a generic name. 
  58. } else { 
  59. $post_type_activity->comments_tracking->admin_filter = _x( 'New item comment posted', 'Post Type generic comments activity admin filter', buddypress ); 
  60.  
  61. $post_type_activity->comments_tracking->format_callback = $post_type_activity->comment_format_callback; 
  62.  
  63. // Check for the comments front filter in the post type labels. 
  64. if ( ! empty( $post_type_object->labels->bp_activity_comments_front_filter ) ) { 
  65. $post_type_activity->comments_tracking->front_filter = $post_type_object->labels->bp_activity_comments_front_filter; 
  66.  
  67. // Fall back to a generic name. 
  68. } else { 
  69. $post_type_activity->comments_tracking->front_filter = _x( 'Item comments', 'Post Type generic comments activity front filter', buddypress ); 
  70.  
  71. $post_type_activity->comments_tracking->contexts = $post_type_activity->contexts; 
  72. $post_type_activity->comments_tracking->position = (int) $post_type_activity->position + 1; 
  73.  
  74. // Try to get the action for new post type comment action on non-multisite installations. 
  75. if ( ! empty( $post_type_object->labels->bp_activity_new_comment ) ) { 
  76. $post_type_activity->comments_tracking->new_post_type_comment_action = $post_type_object->labels->bp_activity_new_comment; 
  77.  
  78. // Try to get the action for new post type comment action on multisite installations. 
  79. if ( ! empty( $post_type_object->labels->bp_activity_new_comment_ms ) ) { 
  80. $post_type_activity->comments_tracking->new_post_type_comment_action_ms = $post_type_object->labels->bp_activity_new_comment_ms; 
  81.  
  82. // Finally make sure we'll be able to find the post type this activity type is associated to. 
  83. $post_type_activity->post_type = $post_type; 
  84.  
  85. /** 
  86. * Filters tracking arguments for a specific post type. 
  87. * @since 2.2.0 
  88. * @param object $post_type_activity The tracking arguments of the post type. 
  89. * @param string $post_type Name of the post type. 
  90. */ 
  91. return apply_filters( 'bp_activity_get_post_type_tracking_args', $post_type_activity, $post_type );