[buddypress-trac] [BuddyPress] #3460: Support custom post types in activity stream
buddypress-trac
noreply at wordpress.org
Tue Nov 26 01:19:08 UTC 2013
#3460: Support custom post types in activity stream
-----------------------------------+-----------------------------
Reporter: boonebgorges | Owner: boonebgorges
Type: enhancement | Status: new
Priority: low | Milestone: Future Release
Component: Activity | Version: 1.2.8
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch |
-----------------------------------+-----------------------------
Changes (by imath):
* cc: math.viet@… (added)
* keywords: 2nd-opinion => 2nd-opinion has-patch
Comment:
Hi,
In France we often say "Jamais 2 sans 3", i guess it applies to this
patch! So this is my third suggestion of patch for this feature.
I've built this version of the patch in WordPress 3.8-beta1 / BuddyPress
1.9-beta1, multisite on.
1/ I've added a new hook to bp-core/bp-core-actions.php :
{{{add_action( 'init', 'bp_catch_post_types', 100 );}}} very late to
maximize the post type catching and i thought it was a safest way than
modifying the priority of bp_init
2/ I've created a new section settings in BuddyPress settings
Administration screen
you'll find a screenshot in the attached files (blogs-settings-
section.png). This new section allows the community administrator to
activate the tracking for the different post types that have been catched.
- if on a multisite config :
* the post type is in a plugin activated on the network : then it
can be activated from the BuddyPress Site Tracking settings and all the
post types will be tracked for the root and the child blogs.
* the post type is only activated on any of the child blogs but
not on the root blog : it cannot be activated in the BuddyPress Site
Tracking settings, so it won't be tracked
* the post type is activated on the root blog : then it can be
activated from the BuddyPress Site Tracking settings and all the post
types will be tracked for the root and if the same plugin has been
activated in any of the child blogs, then they will also be tracked.
- if on a regular config :
* All the post types activated from the BuddyPress site tracking
will be tracked.
To avoid the attachment post type, i'm using {{{get_post_types( array(
'show_in_nav_menus' => true ), 'objects' )}}}, it means that if the
argument 'show_in_nav_menus' for the post type is set to false, it won't
be tracked. This argument if not defined when registering a post type
defaults to the value of the 'public' argument. Avoiding the attachment
post type can be done in another way, but i think it's good then to use
something like {{{get_post_types( array( 'public' => true ), 'objects'
)}}}...
3/ i've added a filter to let a child blog eventually remove a trackable
post type for its particular case :
{{{apply_filters( 'bp_blogs_post_type_trackable', bp_get_option( 'bp-
enabled-post-types', array() ), $blog_id )}}}
Finally the community administrator decides what post types can be
tracked, plugins cannot force using the 'bp_tracking' support. But plugins
can still include arguments to override the default way of formatting
activities. For instance a plugin can include in its post type arguments
the "bp_tracking" array :
{{{
$args_post_type = array(
'label' => __( 'Random' ),
'labels' => array( /*the different labels */ ),
'public' => true,
'bp_tracking' => array(
'type_post' =>
'new_random',
'activity_permalink_post_callback' =>
'random_activity_permalink_callback',
'activity_action_post_callback' =>
'random_activity_action_random_callback',
'type_comment' =>
'new_random_comment',
'activity_action_comment_callback' =>
'random_activity_action_comment_callback',
),
'supports' => array( 'title', 'editor', 'author'
),
);
}}}
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3460#comment:51>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list