OCD Plugin Stats
WordPress Plugin Info API (2 posts)

  1. Dan Rossiter
    Posted 3 years ago #


    I was digging into the plugin code and I see that you're currently just scraping content from the HTML side for each plugin. Though this works, WP actually provides an API for retrieving info about plugins.

    Though the method you're using currently works, it's a little less efficient and prone to breaking if WP ever changes their design. The API is documented and will always return what you expect.

    Just my 2 cents :)

    (I love the plugin, btw!)


  2. Dan Rossiter
    Posted 3 years ago #

    Sorry, one other thing. Looks like the formula for calculating overall ratings for all plugins is incorrect. Currently it takes a straight average of the star rating for each, but this assumes the same number of ratings have been given for each plugin, which would almost never be the case.

    The following pseudocode would return a true average of all plugin ratings:

    reviews = 0
    starpts = 0
    foreach plugin
      reviews += plugin.reviews
      starpts += plugin.reviews * plugin.stars
    return starpts / reviews

    This is especially an issue if you have a plugin with no ratings yet. That currently averages in as a zero, which wouldn't make sense since a non-rated plugin is not the same as a plugin that has been rated a zero.

    All the best!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • OCD Plugin Stats
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic