[theme-reviewers] Getting Theme Download Count

Otto otto at ottodestruct.com
Tue Feb 11 08:39:37 UTC 2014


On Tue, Feb 11, 2014 at 2:34 AM, Otto <otto at ottodestruct.com> wrote:

> On Mon, Feb 10, 2014 at 11:55 PM, Bryan Hadaway <bhadaway at gmail.com>wrote:
>
>> If we wanted to get and display the download count for one of our themes,
>> would it be appropriate to...
>>
>
> Define "download count". What number are you expecting, for what theme,
> exactly?
>
> We have a number of assorted stats regarding download count, so it's hard
> to say how to get it without more information about what number you want to
> get. :)
>
> Don't scrape. There's probably an API request for the number you want.
>


If you just want the big number, I guess example code would help cut any
sort of accidental "abuse" off at the pass...


include_once ABSPATH . 'wp-admin/includes/theme.php';
$api = themes_api( 'theme_information', array('slug' => 'twentythirteen',
'fields' => array( 'downloaded' => true ) ) );
var_dump($api->downloaded);

// result:
// int(343090)


I would recommend caching the resulting data somewhere instead of hitting
the API every single time. Like, maybe a 24 hour transient or so?

-Otto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20140211/389baa0e/attachment.html>


More information about the theme-reviewers mailing list