Skip to:
Content

BuddyPress.org

Opened 2 years ago

Last modified 7 weeks ago

#8088 assigned enhancement

Show all comments - enhancement to correctly calculate total comments

Reported by: magland Owned by: imath
Milestone: 10.0.0 Priority: normal
Severity: normal Version: 4.3.0
Component: Activity Keywords: needs-patch
Cc:

Description

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.

Change History (1)

#1 @imath
7 weeks 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 https://codex.buddypress.org/participate-and-contribute/contribute-with-code/ for some documentation on how to build BP patch.

Note: See TracTickets for help on using tickets.