Ticket #7135: 7135.03.patch
File 7135.03.patch, 10.7 KB (added by , 8 years ago) |
---|
-
src/bp-activity/bp-activity-functions.php
3030 3030 $link = $activity_obj->primary_link; 3031 3031 } else { 3032 3032 if ( 'activity_comment' == $activity_obj->type ) { 3033 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/ ';3033 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/#acomment-' . $activity_obj->id; 3034 3034 } else { 3035 3035 $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/'; 3036 3036 } -
src/bp-activity/bp-activity-notifications.php
208 208 * @param int $secondary_item_id In the case of at-mentions, this is the mentioner's ID. 209 209 * @param int $total_items The total number of notifications to format. 210 210 * @param string $format 'string' to get a BuddyBar-compatible notification, 'array' otherwise. 211 * @param int $id The notification ID. 211 212 * @return string $return Formatted @mention notification. 212 213 */ 213 function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {214 function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string', $id = 0 ) { 214 215 $action_filter = $action; 215 216 $return = false; 216 217 $activity_id = $item_id; … … 225 226 $amount = 'single'; 226 227 227 228 if ( (int) $total_items > 1 ) { 228 $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items );229 $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items ); 229 230 $amount = 'multiple'; 230 231 } else { 231 $text = 232 $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname ); 232 233 } 233 234 break; 234 235 … … 242 243 $text = sprintf( __( 'You have %1$d new replies', 'buddypress' ), (int) $total_items ); 243 244 $amount = 'multiple'; 244 245 } else { 245 $link = bp_activity_get_permalink( $activity_id);246 $text =sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname );246 $link = add_query_arg( 'nid', $id, bp_activity_get_permalink( $activity_id ) ); 247 $text = sprintf( __( '%1$s commented on one of your updates', 'buddypress' ), $user_fullname ); 247 248 } 248 249 break; 249 250 … … 257 258 $text = sprintf( __( 'You have %1$d new comment replies', 'buddypress' ), (int) $total_items ); 258 259 $amount = 'multiple'; 259 260 } else { 260 $link = bp_activity_get_permalink( $activity_id);261 $text =sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname );261 $link = add_query_arg( 'nid', $id, bp_activity_get_permalink( $activity_id ) ); 262 $text = sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname ); 262 263 } 263 264 break; 264 265 } … … 365 366 if ( bp_is_active( 'notifications' ) ) { 366 367 bp_notifications_add_notification( array( 367 368 'user_id' => $activity->user_id, 368 'item_id' => $ activity->id,369 'item_id' => $comment_id, 369 370 'secondary_item_id' => $commenter_id, 370 371 'component_name' => buddypress()->activity->id, 371 372 'component_action' => 'update_reply', … … 389 390 if ( bp_is_active( 'notifications' ) ) { 390 391 bp_notifications_add_notification( array( 391 392 'user_id' => $activity_comment->user_id, 392 'item_id' => $ activity_comment->item_id,393 'item_id' => $comment_id, 393 394 'secondary_item_id' => $commenter_id, 394 395 'component_name' => buddypress()->activity->id, 395 396 'component_action' => 'comment_reply', … … 426 427 * Mark at-mention notification as read when user visits the activity with the mention. 427 428 * 428 429 * @since 2.0.0 429 * @since 2.6.0 Mark notifications for 'update_reply' and 'comment_reply' actions430 430 * 431 431 * @param BP_Activity_Activity $activity Activity object. 432 432 */ … … 439 439 return; 440 440 } 441 441 442 /** 443 * Filter here to add the notification actions to mark as read 444 * when the single activity is displayed. 445 * 446 * @since 2.6.0 447 * 448 * @param array $value List of notification actions to mark as read. 449 */ 450 $notification_actions = apply_filters( 'bp_activity_notification_actions_single_activity', array( 451 'new_at_mention', 452 'update_reply', 453 'comment_reply', 454 ) ); 455 456 $user_id = bp_loggedin_user_id(); 457 $component = buddypress()->activity->id; 458 459 foreach ( $notification_actions as $action ) { 460 // Mark as read any notifications for the current user related to this activity item. 461 bp_notifications_mark_notifications_by_item_id( $user_id, $activity->id, $component, $action ); 462 } 442 // Mark as read any notifications for the current user related to this activity item. 443 bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' ); 463 444 } 464 445 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' ); 465 446 466 447 /** 448 * Mark non-mention notifications as read when user visits our read permalink. 449 * 450 * In particular, 'update_reply' and 'comment_reply' notifications are handled 451 * here. See {@link bp_activity_format_notifications()} for more info. 452 * 453 * @since 2.6.0 454 */ 455 function bp_activity_remove_screen_notifications_for_non_mentions() { 456 if ( false === bp_is_active( 'notifications' ) || false === is_singular() || false === is_user_logged_in() || empty( $_GET['nid'] ) ) { 457 return; 458 } 459 460 // Mark notification as read. 461 BP_Notifications_Notification::update( 462 array( 463 'is_new' => false 464 ), 465 array( 466 'user_id' => bp_loggedin_user_id(), 467 'id' => (int) $_GET['nid'] 468 ) 469 ); 470 } 471 add_action( 'bp_screens', 'bp_activity_remove_screen_notifications_for_non_mentions' ); 472 473 /** 467 474 * Delete at-mention notifications when the corresponding activity item is deleted. 468 475 * 469 476 * @since 2.0.0 … … 480 487 } 481 488 } 482 489 add_action( 'bp_activity_deleted_activities', 'bp_activity_at_mention_delete_notification', 10 ); 490 491 /** 492 * Add a notification for post comments to the post author or post commenter. 493 * 494 * Requires "activity stream commenting on blog and forum posts" to be enabled. 495 * 496 * @since 2.6.0 497 * 498 * @param int $activity_id The activity comment ID. 499 * @param WP_Comment $post_type_comment WP Comment object. 500 * @param array $activity_args Activity comment arguments. 501 * @param object $activity_post_object The post type tracking args object. 502 */ 503 function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $post_type_comment, $activity_args, $activity_post_object ) { 504 // If activity comments are disabled for WP posts, stop now! 505 if ( bp_disable_blogforum_comments() || empty( $activity_id ) || false === bp_is_active( 'notifications' ) ) { 506 return; 507 } 508 509 $notified = false; 510 511 // Send a notification to the blog post author. 512 if ( (int) $post_type_comment->post->post_author !== (int) $activity_args['user_id'] ) { 513 // Only add a notification if comment author is a registered user. 514 // @todo Should we remove this restriction? 515 if ( ! empty( $post_type_comment->user_id ) ) { 516 $notified = true; 517 518 bp_notifications_add_notification( array( 519 'user_id' => $post_type_comment->post->post_author, 520 'item_id' => $activity_id, 521 'secondary_item_id' => $post_type_comment->user_id, 522 'component_name' => buddypress()->activity->id, 523 'component_action' => 'update_reply', 524 'date_notified' => $post_type_comment->comment_date_gmt, 525 'is_new' => 1, 526 ) ); 527 } 528 } 529 530 // Send a notification to the parent comment author for follow-up comments. 531 if ( ! empty( $post_type_comment->comment_parent ) ) { 532 $parent_comment = get_comment( $post_type_comment->comment_parent ); 533 534 if ( ! empty( $parent_comment->user_id ) && (int) $parent_comment->user_id !== (int) $activity_args['user_id'] && false === $notified ) { 535 bp_notifications_add_notification( array( 536 'user_id' => $parent_comment->user_id, 537 'item_id' => $activity_id, 538 'secondary_item_id' => $post_type_comment->user_id, 539 'component_name' => buddypress()->activity->id, 540 'component_action' => 'comment_reply', 541 'date_notified' => $post_type_comment->comment_date_gmt, 542 'is_new' => 1, 543 ) ); 544 } 545 } 546 } 547 add_action( 'bp_blogs_comment_sync_activity_comment', 'bp_activity_add_notification_for_synced_blog_comment', 10, 4 ); -
src/bp-activity/bp-activity-template.php
2420 2420 * 2421 2421 * @since 1.8.0 2422 2422 * 2423 *2424 2423 * @return string $link The activity comment permalink. 2425 2424 */ 2426 2425 function bp_get_activity_comment_permalink() { 2427 2426 global $activities_template; 2428 2427 2429 // Check that comment exists. 2428 $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ); 2429 2430 // Used for filter below. 2430 2431 $comment_id = isset( $activities_template->activity->current_comment->id ) 2431 2432 ? $activities_template->activity->current_comment->id 2432 2433 : 0; 2433 2434 2434 // Setup the comment link.2435 $comment_link = ! empty( $comment_id )2436 ? '#acomment-' .$comment_id2437 : false;2438 2439 // Append comment ID to end of activity permalink.2440 $link = bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . $comment_link;2441 2442 2435 /** 2443 2436 * Filters the activity comment permalink. 2444 2437 * -
src/bp-blogs/bp-blogs-functions.php
715 715 bp_activity_update_meta( $activity_id, 'post_url', esc_url_raw( add_query_arg( 'p', $comment->post->ID, home_url( '/' ) ) ) ); 716 716 } 717 717 } 718 719 /** 720 * Fires after an activity comment is added from a WP post comment. 721 * 722 * @since 2.6.0 723 * 724 * @param int $activity_id The activity comment ID. 725 * @param WP_Comment $post_type_comment WP Comment object. 726 * @param array $activity_args Activity comment arguments. 727 * @param object $activity_post_object The post type tracking args object. 728 */ 729 do_action( 'bp_blogs_comment_sync_activity_comment', $activity_id, $comment, $activity_args, $activity_post_object ); 718 730 } 719 731 } 720 732