bp_activity_format_activity_action_custom_post_type_post( string $action, object $activity )
Format activity action strings for custom post types.
Description
Parameters
- $action
-
(Required) Static activity action.
- $activity
-
(Required) Activity data object.
Return
(string) $action
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_format_activity_action_custom_post_type_post( $action, $activity ) { $bp = buddypress(); // Fetch all the tracked post types once. if ( empty( $bp->activity->track ) ) { $bp->activity->track = bp_activity_get_post_types_tracking_args(); } if ( empty( $activity->type ) || empty( $bp->activity->track[ $activity->type ] ) ) { return $action; } $user_link = bp_core_get_userlink( $activity->user_id ); $blog_url = get_home_url( $activity->item_id ); if ( empty( $activity->post_url ) ) { $post_url = add_query_arg( 'p', $activity->secondary_item_id, trailingslashit( $blog_url ) ); } else { $post_url = $activity->post_url; } if ( is_multisite() ) { $blog_link = '<a href="' . esc_url( $blog_url ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>'; if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action_ms ) ) { $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action_ms, $user_link, $post_url, $blog_link ); } else { $action = sprintf( __( '%1$s wrote a new <a href="%2$s">item</a>, on the site %3$s', 'buddyboss' ), $user_link, esc_url( $post_url ), $blog_link ); } } else { if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_action ) ) { $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_action, $user_link, $post_url ); } else { $action = sprintf( __( '%1$s wrote a new <a href="%2$s">item</a>', 'buddyboss' ), $user_link, esc_url( $post_url ) ); } } /** * Filters the formatted custom post type activity post action string. * * @since BuddyPress 2.2.0 * * @param string $action Activity action string value. * @param BP_Activity_Activity $activity Activity item object. */ return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity ); }
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.