Advertisement
vapvarun

Display Product with Featured Image in BuddyPress activity

Feb 9th, 2021
1,095
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. add_post_type_support( 'product', 'buddypress-activity' );
  2.  
  3. function customize_page_tracking_args() {
  4.     // Check if the Activity component is active before using it.
  5.     if ( ! bp_is_active( 'activity' ) ) {
  6.         return;
  7.     }
  8.  
  9.     bp_activity_set_post_type_tracking_args( 'product', array(
  10.          'component_id'             => 'activity',
  11.         'action_id'                => 'new_product',
  12.         'bp_activity_admin_filter' => __( 'Published a new badlee',
  13. 'custom-domain' ),
  14.         'bp_activity_front_filter' => __( 'product', 'twinkools' ),
  15.         'contexts'                 => array( 'activity', 'member' ),
  16.         'activity_comment'         => true,
  17.         'bp_activity_new_post'     => __( '%1$s posted a new <a
  18. href="%2$s">product</a>', 'twinkools' ),
  19.         'position'                 => 100,
  20.     ) );
  21. }
  22. add_action( 'init', 'customize_page_tracking_args', 1000 );
  23.  
  24. function record_cpt_activity_content_featured_image( $cpt ) {
  25.  
  26.     if ( 'new_product' === $cpt['type'] ) {
  27.  
  28.         global $wpdb, $post, $bp;
  29.         $theimg = wp_get_attachment_image_src(  get_post_thumbnail_id(
  30. bp_get_activity_secondary_item_id() ), 'large' );
  31.         $cpt['content'] .= '<img src="' . $theimg[0] . '">';
  32.     }
  33.  
  34.     return $cpt;
  35. }
  36. add_filter('bp_before_activity_add_parse_args','record_cpt_activity_content_featured_image');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement