Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/07/2016 04:29:52 PM (4 years ago)
Author:
imath
Message:

Post Type Activities: allow post types to register comments tracking

When registering a post type, it is now possible to inform BuddyPress the comments about this post type need to be tracked into the activity stream. This can be achieved by making sure the post type supports "comments" and "buddypress-activity" and by adding extra parameters to the "bp_activity" argument of the register_post_type() function one or by using the bp_activity_set_post_type_tracking_args() function.

We are also introducing a new function to inform if an activity type is supporting a specific feature: bp_activity_type_supports(). For now this function is helping to check if:

  • a activity supports a an activity comment
  • an activity comment supports synchronization with a post type comment

Props shanebp, r-a-y.

See #6482

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r10516 r10542  
    30303030    $bp = buddypress();
    30313031
    3032     // Assume activity can be commented on.
    3033     $can_comment = true;
    3034 
    3035     // Determine ability to comment based on activity action name.
    3036     $activity_action = bp_get_activity_action_name();
    3037 
    3038     $turn_off = 0;
    3039     if ( ! empty( $activities_template->disable_blogforum_replies ) ) {
    3040         $turn_off = 1;
    3041     }
    3042 
    3043     $maybe_turn_off = array_fill_keys( array(
    3044         'new_blog_post',
    3045         'new_blog_comment',
    3046         'new_forum_topic',
    3047         'new_forum_post',
    3048     ), $turn_off );
    3049 
    3050     $maybe_turn_off['activity_comment'] = 1;
    3051 
    3052     // Fetch all the tracked post types once.
    3053     if ( empty( $bp->activity->track ) ) {
    3054         $bp->activity->track = bp_activity_get_post_types_tracking_args();
    3055     }
    3056 
    3057     foreach ( $bp->activity->track as $action => $tracking_args ) {
    3058         if ( empty( $tracking_args->activity_comment ) ) {
    3059             $maybe_turn_off[ $action ] = $turn_off;
    3060         }
    3061     }
    3062 
    3063     $can_comment = empty( $maybe_turn_off[ $activity_action ] );
     3032    // Determine ability to comment based on activity type name.
     3033    $activity_type = bp_get_activity_type();
     3034
     3035    // Get the 'comment-reply' support for the current activity type.
     3036    $can_comment = bp_activity_type_supports( $activity_type, 'comment-reply' );
     3037
     3038    // Neutralize activity_comment.
     3039    if ( 'activity_comment' === $activity_type ) {
     3040        $can_comment = false;
     3041    }
    30643042
    30653043    /**
     
    30673045     *
    30683046     * @since 1.5.0
     3047     * @since 2.5.0 Use $activity_type instead of $activity_name for the second parameter.
    30693048     *
    30703049     * @param bool   $can_comment     Status on if activity can be commented on.
    3071      * @param string $activity_action Current activity action being checked on.
    3072      */
    3073     return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
     3050     * @param string $activity_type   Current activity type being checked on.
     3051     */
     3052    return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_type );
    30743053}
    30753054
Note: See TracChangeset for help on using the changeset viewer.