Track your WordPress.org Plugin Stats on Your Site

How to track your WordPress.org plugins statistics and display them as a widget within your own theme.



Note:This information is pulled from the Automattic plugin page.

In this quick tutorial, I will show you how to track your WordPress.org plugins statistics and display them as a widget within your own theme.

The code below will be included in your functions.php but you can easily create a plugin using the same approach. Also, if you store the data into your database you can display daily, weekly or monthly trends for downloads, ratings, and trends.

In addition, there is an array with 1, 2, 3, 4, 5-star ratings which can be used and displayed as well.

Let us get started.

The Code

First, we need to add a couple of actions; the first one is to add some basic styling to our dashboard widget layout. And the second one creates and positions our widget within the Dashboard area.

Next, we have a plugin_tracker() function that will handle the actual data gathering form the WordPress plugin API and then display the HTML with formatted data for each plugin from the query.

Subscribe to our Newsletter* if you find our content useful and would like to receive regular updates with the latest posts.

Here is the URL we use to get the plugin data (this will give us the last 10 plugins from the author) https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[author]=automattic

You can also use request[page]=2 if you want to get the next 10 results and so on.

For additional information, you can visit the older WordPress.org API page https://codex.wordpress.org/WordPress.org_API

What’s next?

You can improve and modify the code above to get daily/weekly results, have pagination and track your plugin statistics within your own site.

Hope this was useful quick tutorial.

‘Til the next one.

* We have a NO SPAM policy so you won't reaceive any meaningless emails from us!

Related Content

Adding License Key Feature to Your Premium WordPress Theme or Plugin (2/3)

How to set up our API server and link up the previously created functions with our server app.

READ MORE...

Integrate Bitly Short URLs Within WordPress

How to use Bitly to generate short URLs and track your social media clicks.

READ MORE...

Adding License Key Feature to Your Premium WordPress Theme or Plugin (3/3)

How to use your API server and glue everything we have done so far together.

READ MORE...

Leave a Reply

Your email address will not be published. Required fields are marked *

Overwrite and Send Custom Emails in WordPress
Integrate Bitly Short URLs Within WordPress

Thank you for reading our content. Use the buttons below to spread the love and share Adding License Key Feature to Your Premium WordPress Theme or Plugin (3/3) with your followers.