Skip to:

Opened 5 years ago

Closed 3 years ago

#8088 closed enhancement (fixed)

Show all comments - enhancement to correctly calculate total comments

Reported by: magland's profile magland Owned by: imath's profile imath
Milestone: 10.0.0 Priority: normal
Severity: normal Version: 4.3.0
Component: Templates Keywords: needs-patch


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 (4)

#1 @imath
3 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 10.0.0
  • Owner set to imath
  • Status changed from new to assigned

Hi, thanks for your report.

Let's have a look at it during 10.0.0, I'd like to see a patch about it for both Template packs (Nouveau & Legacy), if possible. See for some documentation on how to build BP patch.

This ticket was mentioned in Slack in #buddypress by imath. View the logs.

3 years ago

#3 @imath
3 years ago

  • Component changed from Activity to Templates

#4 @imath
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 13190:

BP Legacy: Improve the Activity "Show All" comments count

Props magland

Fixes #8088

Note: See TracTickets for help on using tickets.