diff --git src/bp-messages/bp-messages-notifications.php src/bp-messages/bp-messages-notifications.php
index 8b700de04..44a3f1b0f 100644
|
|
add_action( 'thread_loop_start', 'bp_messages_screen_conversation_mark_notificat |
215 | 215 | * @since 3.0.0 |
216 | 216 | * |
217 | 217 | * @param int $thread_id ID of the thread being marked as read. |
| 218 | * @param int $num_rows The number of affected rows by the "mark read" update query. |
218 | 219 | */ |
219 | | function bp_messages_mark_notification_on_mark_thread( $thread_id ) { |
| 220 | function bp_messages_mark_notification_on_mark_thread( $thread_id, $num_rows = 0 ) { |
| 221 | if ( ! $num_rows ) { |
| 222 | return; |
| 223 | } |
| 224 | |
220 | 225 | $thread_messages = BP_Messages_Thread::get_messages( $thread_id ); |
221 | 226 | |
222 | 227 | foreach ( $thread_messages as $thread_message ) { |
223 | 228 | bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $thread_message->id, buddypress()->messages->id, 'new_message' ); |
224 | 229 | } |
225 | 230 | } |
226 | | add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread' ); |
| 231 | add_action( 'messages_thread_mark_as_read', 'bp_messages_mark_notification_on_mark_thread', 10, 2 ); |
227 | 232 | |
228 | 233 | /** |
229 | 234 | * When a message is deleted, delete corresponding notifications. |
diff --git src/bp-messages/classes/class-bp-messages-thread.php src/bp-messages/classes/class-bp-messages-thread.php
index 770e58434..34049f007 100644
|
|
class BP_Messages_Thread { |
625 | 625 | bp_displayed_user_id() : |
626 | 626 | bp_loggedin_user_id(); |
627 | 627 | |
628 | | $bp = buddypress(); |
629 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 628 | $bp = buddypress(); |
| 629 | $num_rows = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
630 | 630 | |
631 | 631 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
632 | 632 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
… |
… |
class BP_Messages_Thread { |
635 | 635 | * Fires when messages thread was marked as read. |
636 | 636 | * |
637 | 637 | * @since 2.8.0 |
| 638 | * @since 8.0.0 Passes the number of affected rows into the action. |
638 | 639 | * |
639 | 640 | * @param int $thread_id The message thread ID. |
| 641 | * @param int|false $num_rows The number of affected rows by the update query. |
| 642 | * False on error. |
640 | 643 | */ |
641 | | do_action( 'messages_thread_mark_as_read', $thread_id ); |
| 644 | do_action( 'messages_thread_mark_as_read', $thread_id, $num_rows ); |
642 | 645 | |
643 | | return $retval; |
| 646 | return $num_rows; |
644 | 647 | } |
645 | 648 | |
646 | 649 | /** |
… |
… |
class BP_Messages_Thread { |
660 | 663 | bp_displayed_user_id() : |
661 | 664 | bp_loggedin_user_id(); |
662 | 665 | |
663 | | $bp = buddypress(); |
664 | | $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
| 666 | $bp = buddypress(); |
| 667 | $num_rows = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $user_id, $thread_id ) ); |
665 | 668 | |
666 | 669 | wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); |
667 | 670 | wp_cache_delete( $user_id, 'bp_messages_unread_count' ); |
… |
… |
class BP_Messages_Thread { |
670 | 673 | * Fires when messages thread was marked as unread. |
671 | 674 | * |
672 | 675 | * @since 2.8.0 |
| 676 | * @since 8.0.0 Passes the number of affected rows into the action. |
673 | 677 | * |
674 | 678 | * @param int $thread_id The message thread ID. |
| 679 | * @param int|false $num_rows The number of affected rows by the update query. |
| 680 | * False on error. |
675 | 681 | */ |
676 | | do_action( 'messages_thread_mark_as_unread', $thread_id ); |
| 682 | do_action( 'messages_thread_mark_as_unread', $thread_id, $num_rows ); |
677 | 683 | |
678 | | return $retval; |
| 684 | return $num_rows; |
679 | 685 | } |
680 | 686 | |
681 | 687 | /** |