Skip to:

Opened 2 years ago

#8088 new enhancement

Show all comments - enhancement to correctly calculate total comments

Reported by: magland Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.3.0
Component: Activity 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:

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.

Change History (0)

Note: See TracTickets for help on using tickets.