jaredatch / Shared-Counts

WordPress plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts.
GNU General Public License v2.0
47 stars 16 forks source link

Fixes #107: Correct the facebook likes, comment and shares count. #108

Closed hansschuijff closed 2 years ago

hansschuijff commented 3 years ago

Description

The Facebook share, comment and like count wasn't correctly retrieved in Shared_Counts_Core->count(). Instead of retrieving them from $counts['Facebook'], they where retrieved from $counts where they didn't exist.

Also where the api result is retrieved (Shared_Counts_Core->query_sharedcount_api()) the like_count wasn't correctly retrieved, since it is called "reaction_count" there instead of 'like_count'. So now the correct Facebook Likes count is retrieved and shown.

What I didn't fix is that the number presented by adding the total counts service counts facebook shares and facebook likes double when they are added as service in combination with the general facebook service.

The latter already contains the sum of likes, shares and comments and adding the fb likes an fb shares service will again add those counts to the total making the end result the correct sum of all the services, but it doesn't reflect the correct number of social interactions.

So it might be more correct to only count them once, although in practice it might not be a problem when most users just add one or the other.

107

Testing procedure

The retrieval of the likes count from the api, I tested in admin, by opening a post in the editor that had all types of Facebook counts and checking if all numbers where there and if the sum adds up. I also var_dumped the count arrays and results at one point, mainly to check how the total was build. The count on the frontend I just tested by adding and removing services in the settings and seeing the result.

Types of changes

Checklist: