bp_blogs_register_post_tracking_args( object|null $params = null, string|int $post_type )

Set up the tracking arguments for the ‘post’ post type.


Description Description

See also See also


Top ↑

Parameters Parameters

$params

(object|null) (Optional) Tracking arguments.

Default value: null

$post_type

(string|int) (Required) Post type to track.


Top ↑

Return Return

(object|null)


Top ↑

Source Source

File: bp-blogs/bp-blogs-activity.php

function bp_blogs_register_post_tracking_args( $params = null, $post_type = 0 ) {

	/**
	 * Filters the post types to track for the Blogs component.
	 *
	 * @since 1.5.0
	 * @deprecated 2.3.0
	 *
	 * Make sure plugins still using 'bp_blogs_record_post_post_types'
	 * to track their post types will generate new_blog_post activities
	 * See https://buddypress.trac.wordpress.org/ticket/6306
	 *
	 * @param array $value Array of post types to track.
	 */
	$post_types = apply_filters( 'bp_blogs_record_post_post_types', array( 'post' ) );
	$post_types_array = array_flip( $post_types );

	if ( ! isset( $post_types_array[ $post_type ] ) ) {
		return $params;
	}

	// Set specific params for the 'post' post type.
	$params->component_id    = buddypress()->blogs->id;
	$params->action_id       = 'new_blog_post';
	$params->admin_filter    = __( 'New post published', 'buddypress' );
	$params->format_callback = 'bp_blogs_format_activity_action_new_blog_post';
	$params->front_filter    = __( 'Posts', 'buddypress' );
	$params->contexts        = array( 'activity', 'member' );
	$params->position        = 5;

	if ( post_type_supports( $post_type, 'comments' ) ) {
		$params->comment_action_id = 'new_blog_comment';

		/**
		 * Filters the post types to track for the Blogs component.
		 *
		 * @since 1.5.0
		 * @deprecated 2.5.0
		 *
		 * Make sure plugins still using 'bp_blogs_record_comment_post_types'
		 * to track comment about their post types will generate new_blog_comment activities
		 * See https://buddypress.trac.wordpress.org/ticket/6306
		 *
		 * @param array $value Array of post types to track.
		 */
		$comment_post_types = apply_filters( 'bp_blogs_record_comment_post_types', array( 'post' ) );
		$comment_post_types_array = array_flip( $comment_post_types );

		if ( isset( $comment_post_types_array[ $post_type ] ) ) {
			$params->comments_tracking = new stdClass();
			$params->comments_tracking->component_id    = buddypress()->blogs->id;
			$params->comments_tracking->action_id       = 'new_blog_comment';
			$params->comments_tracking->admin_filter    = __( 'New post comment posted', 'buddypress' );
			$params->comments_tracking->format_callback = 'bp_blogs_format_activity_action_new_blog_comment';
			$params->comments_tracking->front_filter    = __( 'Comments', 'buddypress' );
			$params->comments_tracking->contexts        = array( 'activity', 'member' );
			$params->comments_tracking->position        = 10;
		}
	}

	return $params;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.