Skip to:
Content

BuddyPress.org

Changeset 8955


Ignore:
Timestamp:
08/22/2014 03:43:26 PM (12 years ago)
Author:
johnjamesjacoby
Message:

In bp_activity_can_comment_reply() check for and allow an empty $comment parameter, and set to bp_activity_current_comment() if so. This prevents debug notices and allows for cleaner comparisons in template parts.

File:
1 edited

Legend:

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

    r8787 r8955  
    25932593
    25942594                $url = wp_nonce_url( $url, 'bp_activity_delete_link' );
    2595                                
     2595
    25962596                return apply_filters( 'bp_get_activity_delete_url', $url );
    25972597        }
    … …  
    27642764        $activity_action = bp_get_activity_action_name();
    27652765        switch ( $activity_action ) {
    2766                
     2766
    27672767                // Maybe turn off for blog and forum updates
    27682768                case 'new_blog_post'    :
    … …  
    27932793 *         false.
    27942794 */
    2795 function bp_activity_can_comment_reply( $comment ) {
     2795function bp_activity_can_comment_reply( $comment = '' ) {
    27962796
    27972797        // Assume activity can be commented on
    27982798        $can_comment = true;
    27992799
    2800         // Fall back on current comment in activity loop
    2801         $comment_depth = isset( $comment->depth )
    2802                 ? intval( $comment->depth )
    2803                 : bp_activity_get_comment_depth();
    2804 
    2805         // Threading is turned on, so check the depth
    2806         if ( get_option( 'thread_comments' ) ) {
    2807                 $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
    2808 
    2809         // No threading for comment replies if no threading for comments
    2810         } else {
    2811                 $can_comment = false;
    2812         }
    2813 
    2814         return apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
     2800        // Check that comment exists
     2801        if ( empty( $comment ) ) {
     2802                $comment = bp_activity_current_comment();
     2803        }
     2804
     2805        if ( ! empty( $comment ) ) {
     2806
     2807                // Fall back on current comment in activity loop
     2808                $comment_depth = isset( $comment->depth )
     2809                        ? intval( $comment->depth )
     2810                        : bp_activity_get_comment_depth();
     2811
     2812                // Threading is turned on, so check the depth
     2813                if ( get_option( 'thread_comments' ) ) {
     2814                        $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
     2815
     2816                // No threading for comment replies if no threading for comments
     2817                } else {
     2818                        $can_comment = false;
     2819                }
     2820        }
     2821
     2822        return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
    28152823}
    28162824
    … …  
    28692877                return apply_filters( 'bp_get_total_favorite_count_for_user', $retval );
    28702878        }
    2871        
     2879
    28722880
    28732881/**
    … …  
    31893197         */
    31903198        function bp_activity_recurse_comments_user_ids( array $comments = array() ) {
    3191                
     3199
    31923200                // Default user ID's array
    31933201                $user_ids = array();
    … …  
    33603368                if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
    33613369                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
    3362                        
     3370
    33633371                // Friend feed link
    33643372                } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
    33653373                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
    3366                        
     3374
    33673375                // Group feed link
    3368                 } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) { 
     3376                } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
    33693377                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
    33703378
    … …  
    33723380                } elseif ( 'favorites' === bp_current_action() ) {
    33733381                        $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
    3374                        
     3382
    33753383                // Mentions activity feed link
    33763384                } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
Note: See TracChangeset for help on using the changeset viewer.