[buddypress-trac] [BuddyPress Trac] #8088: Show all comments - enhancement to correctly calculate total comments

buddypress-trac noreply at wordpress.org
Wed May 1 09:39:03 UTC 2019


#8088: Show all comments - enhancement to correctly calculate total comments
-------------------------+-----------------------------
 Reporter:  magland      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Activity     |    Version:  4.3.0
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 On the activity timeline posts with lots of comments have an option to
 'Show all comments (x)'

 The x in brackets is a count of the total amount of comments calculated by
 javascript:

 {{{
 (i=jq("#"+e.attr("id")+" li").length)
 }}}

 The calculation is in buddypress.min.js in /wp-content/plugins/buddypress
 /bp-templates/bp-legacy/js/buddypress.min.js

 This causes an issue when a plugin adds further list elements into the
 comments area.

 One example is the activity reactions plugin:
 https://mg.wordpress.org/plugins/activity-reactions-for-buddypress/

 Each reaction is enclosed in a list element, these additional li elements
 cause the total count to be wrong.

 I have fixed this by modifying the calculation to be more specific and
 only count li elements that are comment elements as below:

 {{{
 (i=jq("#"+e.attr("id")+" li[id*=\"acomment-\"]").length)
 }}}


 While not a bug in buddypress itself this change does ensure more
 compatibility if plugins alter the html code in the comments area.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8088>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list