Calculate downloads floor

I wanted to calculate the ratio of active theme installs versus theme downloads, but the calculation often seemed very unfair, for example when a theme has been downloaded 999 times, the “active_installs” number would reflect that as 900  on the WordPress API because it lists theme and plugin count in very round numbers ( 10s, 100s, 1000s, etc. ).

So to equalize things just a little bit – I made this little function:

<?php
function download_floor($downloads) {
$length = strlen( $downloads );
$divider = intval( '1' . str_repeat( '0', $length1 ) );
return floor( $downloads / $divider ) * $divider;
}

view raw
download_floor.php
hosted with ❤ by GitHub

I don’t know whether this is how WordPress is doing it, but for me, it seems to do the trick.

Leave a Reply

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