Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function webinars_activity_args() {
- if ( ! bp_is_active( 'activity' ) ) {
- return;
- }
- add_post_type_support( 'webinars', 'buddypress-activity' );
- bp_activity_set_post_type_tracking_args( 'webinars', array(
- 'component_id' => 'activity',
- 'action_id' => 'new_webinars',
- 'bp_activity_admin_filter' => __( 'Published a new Webinar', 'text-domain' ),
- 'bp_activity_front_filter' => __( 'Webinar', 'text-domain' ),
- 'contexts' => array( 'activity', 'member' ),
- 'activity_comment' => true,
- 'bp_activity_new_post' => __( '%1$s posted a new Webinar: <a href="%2$s">[Webinar]</a>', 'text-domain' ),
- 'bp_activity_new_post_ms' => __( '%1$s posted a new Webinar: <a href="%2$s">[Webinar]</a>, on the site %3$s', 'text-domain' ),
- 'position' => 100,
- ) );
- }
- add_action( 'init', 'webinars_activity_args' );
- function webinars_include_post_type_title( $action, $activity ) {
- if ( empty( $activity->id ) ) {
- return $action;
- }
- if ( 'new_webinars' != $activity->type ) {
- return $action;
- }
- preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches );
- if ( empty( $matches[1][1] ) || '[Webinars]' != $matches[1][1] ) {
- return $action;
- }
- $post_type_title = bp_activity_get_meta( $activity->id, 'post_title' );
- if ( empty( $post_type_title ) ) {
- switch_to_blog( $activity->item_id );
- $post_type_title = get_post_field( 'post_title', $activity->secondary_item_id );
- // We have a title save it in activity meta to avoid switching blogs too much
- if ( ! empty( $post_type_title ) ) {
- bp_activity_update_meta( $activity->id, 'post_title', $post_type_title );
- }
- restore_current_blog();
- }
- return str_replace( $matches[1][1], esc_html( $post_type_title ), $action );
- }
- add_filter( 'bp_activity_custom_post_type_post_action', 'webinars_include_post_type_title', 10, 2 );
Add Comment
Please, Sign In to add comment