diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
index 194f25dc61..73ebb19680 100644
--- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
+++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
@@ -292,23 +292,8 @@ public static function format_active_installs_for_display( $count ) {
* @return int The sanitized version for display.
*/
public static function sanitize_active_installs( $active_installs ) {
- if ( $active_installs > 10000000 ) {
- // 10 million +
- return 10000000;
- } elseif ( $active_installs > 1000000 ) {
- $round = 1000000;
- } elseif ( $active_installs > 100000 ) {
- $round = 100000;
- } elseif ( $active_installs > 10000 ) {
- $round = 10000;
- } elseif ( $active_installs > 1000 ) {
- $round = 1000;
- } elseif ( $active_installs > 100 ) {
- $round = 100;
- } else {
- // Rounded to ten, else 0
- $round = 10;
- }
+ $length = strlen( (string) $active_installs );
+ $round = pow( 10, max( 1, $length - 1 ) );
return floor( $active_installs / $round ) * $round;
}
diff --git a/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php b/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php
index 863d0a4a2f..178de13911 100644
--- a/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php
+++ b/wordpress.org/public_html/wp-content/plugins/theme-directory/rest-api/class-internal.php
@@ -155,21 +155,8 @@ function bulk_update_stats( $request ) {
* @return int The sanitized version for display.
*/
protected function sanitize_active_installs( $active_installs ) {
- if ( $active_installs > 1000000 ) {
- // 1 million +;
- return 1000000;
- } elseif ( $active_installs > 100000 ) {
- $round = 100000;
- } elseif ( $active_installs > 10000 ) {
- $round = 10000;
- } elseif ( $active_installs > 1000 ) {
- $round = 1000;
- } elseif ( $active_installs > 100 ) {
- $round = 100;
- } else {
- // Rounded to ten, else 0
- $round = 10;
- }
+ $length = strlen( (string) $active_installs );
+ $round = pow( 10, max( 1, $length - 1 ) );
return floor( $active_installs / $round ) * $round;
}