bp_activity_set_post_type_tracking_args( string $post_type = '', array $args = array() )
Set tracking arguments for a given post type.
Description
Parameters
- $post_type
-
(string) (Optional) The name of the post type, as registered with WordPress. Eg 'post' or 'page'.
Default value: ''
- $args
-
(array) (Optional) An associative array of tracking parameters. All items are optional.
- 'bp_activity_admin_filter'
(string) String to use in the Dashboard > Activity dropdown. - 'bp_activity_front_filter'
(string) String to use in the front-end dropdown. - 'bp_activity_new_post'
(string) String format to use for generating the activity action. Should be a translatable string where %1$s is replaced by a user link and %2$s is the URL of the newly created post. - 'bp_activity_new_post_ms'
(string) String format to use for generating the activity action on Multisite. Should be a translatable string where %1$s is replaced by a user link, %2$s is the URL of the newly created post, and %3$s is a link to the site. - 'component_id'
(string) ID of the BuddyPress component to associate the activity item. - 'action_id'
(string) Value for the 'type' param of the new activity item. - 'format_callback'
(callable) Callback for formatting the activity action string. Default: 'bp_activity_format_activity_action_custom_post_type_post'. - 'contexts'
(array) The directory contexts in which the filter will show. Default: array( 'activity' ). - 'position'
(array) Position of the item in filter dropdowns. - 'singular'
(string) Singular, translatable name of the post type item. If no value is provided, it's pulled from the 'singular_name' of the post type. - 'activity_comment'
(bool) Whether to allow comments on the activity items. Defaults to true if the post type does not natively support comments, otherwise false.
Default value: array()
- 'bp_activity_admin_filter'
Return
(bool)
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_set_post_type_tracking_args( $post_type = '', $args = array() ) { global $wp_post_types; if ( empty( $wp_post_types[ $post_type ] ) || ! post_type_supports( $post_type, 'buddypress-activity' ) || ! is_array( $args ) ) { return false; } $activity_labels = array( /* Post labels */ 'bp_activity_admin_filter', 'bp_activity_front_filter', 'bp_activity_new_post', 'bp_activity_new_post_ms', /* Comment labels */ 'bp_activity_comments_admin_filter', 'bp_activity_comments_front_filter', 'bp_activity_new_comment', 'bp_activity_new_comment_ms' ); // Labels are loaded into the post type object. foreach ( $activity_labels as $label_type ) { if ( ! empty( $args[ $label_type ] ) ) { $wp_post_types[ $post_type ]->labels->{$label_type} = $args[ $label_type ]; unset( $args[ $label_type ] ); } } // If there are any additional args, put them in the bp_activity attribute of the post type. if ( ! empty( $args ) ) { $wp_post_types[ $post_type ]->bp_activity = $args; } }
Changelog
Version | Description |
---|---|
BuddyPress 2.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.