[buddypress-trac] [BuddyPress Trac] #3460: Support custom post types in activity stream

buddypress-trac noreply at wordpress.org
Sat Mar 15 00:03:06 UTC 2014

#3460: Support custom post types in activity stream
 Reporter:  boonebgorges                         |       Owner:
     Type:  enhancement                          |  boonebgorges
 Priority:  low                                  |      Status:  new
Component:  Activity                             |   Milestone:  Future
 Severity:  normal                               |  Release
 Keywords:  2nd-opinion has-patch needs-testing  |     Version:  1.2.8
                                                 |  Resolution:
Changes (by imath):

 * keywords:  2nd-opinion has-patch => 2nd-opinion has-patch needs-testing


 I'm back on this ticket !

 I've built a new patch to take in account improvements boonebgorges
 introduced in r8125 & r8126 to dynamically generate activity actions.

 I think i've never been so close to "touchdown" with this ticket :)

 So 3460.06.diff will require trunk > 8126 (of course see first paragraph).
 It's a bit less complex than its predecessors actually.

 I've created a class {{{BP_Blogs_Post_Type_Tracker}}} that hooks
 'bp_blogs_register_activity_actions' to set the activity actions ( after
 hooking init in the class at a 1000 priority, to be sure i catch all post
 types !).

 In its {{{setup_post_types()}}} method, it uses by default
 'bp_blogs_format_activity_action_new_blog_post' &&
 'bp_blogs_format_activity_action_new_blog_comment' for each post type.
 But if a post type has a BuddyPress specific argument (bp_tracking), he
 can override these default values in favor of it's own function.
 For instance
 $args_post_type = array(
         'label'             => __( 'Photo Sets', 'buddypress' ),
         'labels'            => $labels_photo_sets,
         'public'            => true,
         'rewrite'           => false,
         'show_ui'           => true,
         'show_in_admin_bar' => false,
         'supports'          => array( 'title', 'editor', 'author' ),
         'bp_tracking'       => array(
                 'post_callback'    => 'the_format_function_for_posts',
                 'comment_callback' => 'the_format_function_for_comments',

 I've needed to edit a bit
 {{{bp_blogs_format_activity_action_new_blog_post()}}} &&
 {{{bp_blogs_format_activity_action_new_blog_comment()}}} formatting
 functions so that they could work with any post types. I had to create a
 new activity meta to store the post_type value for each post type.
 Boone : as you will see, i treat post like a post type. So if the patch
 does not make it for 2.0, later we will need to add an extra check for
 this "legacy" post_type ;)

 I've maintained the "subsite" Network Tracking settings submenu :
 - i think it's easier this way to catch post types that are specific to
 child blogs
 - it gives a way to sub blog Administrator to customize the post type that
 are tracked, by adding or removing them. For instance if page post type is
 active on root blog, the child blog can decide not to track his page post
 - i've added a setting in BuddyPress Network settings to let Super
 Administrators eventually restrict this access.

 Tested it in Multisite and regular configs. Seems to work fine :)

 Thanks in advance for your eyes on this one.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3460#comment:68>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac

More information about the buddypress-trac mailing list