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

Facebook counts like, comment and share counts are not shown #107

Closed hansschuijff closed 2 years ago

hansschuijff commented 3 years ago

I already posted most of this in wordpress.org, support (4 months ago, no response), but also found one extra bug. I will issue a PR with the corrected source code.

There is an error in class-shared-count-core.php that results in facebook likes not being retrieved from the api at all and in not displaying the comments and shares on the frontend when those share buttons are selected. Only the facebook total is correct and probably most people only use that, but I had used share instead and later noticed that the facebook total reported in the metabox didn't match the sum of the other facebook counts.

The problem was twofold:

  1. the source has three occasions where the ["facebook"] array-level has been omitted (line 212, 215 and 218)
  2. and the api doesn't return "like_count" for facebook, but "reaction_count". So since $results['facebook']['like_count'] was never found in the api-results, it always remained 0. It should be $results['facebook']['reaction_count'] instead. (on line 478).

Plugin version

1.3.0

Current Behavior

In the metabox in the editor the value of like_count is always reported as 0. on the frontend no count is reported for facebook like, comments or share buttons.

Expected Behavior

In the metabox and on the facebook like, share and comment buttons the correct count should be reported.

Possible Solution

I will issue a pr with the corrected lines.