Making WordPress.org


Ignore:
Timestamp:
06/02/2026 02:49:33 AM (5 months ago)
Author:
dd32
Message:

Plugin Directory: Update GeoPattern to 1.1.2 and tidy generated icon output

Props dd32, slaFFik.
Closes ​https://github.com/WordPress/wordpress.org/pull/659.
Fixes #8270.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/geopattern-1.1.2
Files:
3 added
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/libs/geopattern-1.1.2/GeoPattern/SVGElements/Base.php

    r14926 r14927  
    1212    }
    1313
     14    // WordPress.org: round generated floats (opacity, coordinates, transforms) to 3 decimal
     15    // places. The upstream generator emits full PHP precision, e.g. fill-opacity="0.080666666666667",
     16    // which is invisible once rendered but inflates every icon. See https://meta.trac.wordpress.org/ticket/8270.
     17    protected function trimPrecision($value)
     18    {
     19        return preg_replace_callback(
     20            '/-?\d*\.\d+/',
     21            function ($matches) {
     22                return rtrim(rtrim(number_format((float) $matches[0], 3, '.', ''), '0'), '.');
     23            },
     24            (string) $value
     25        );
     26    }
     27
    1428    public function elementsToString()
    1529    {
    … …  
    1731        foreach ($this->elements as $key => $value)
    1832        {
    19             $string .= "$key=\"$value\" ";
     33            $string .= "$key=\"".$this->trimPrecision($value)."\" ";
    2034        }
    2135        return $string;
    … …  
    3246                foreach ($value as $k => $v)
    3347                {
    34                     $string .= "$k:$v;";
     48                    $string .= "$k:".$this->trimPrecision($v).";";
    3549                }
    3650                $string .= '" ';
    … …  
    3852            else
    3953            {
    40                 $string .= "$key=\"$value\" ";
     54                $string .= "$key=\"".$this->trimPrecision($value)."\" ";
    4155            }
    4256        }
Note: See TracChangeset for help on using the changeset viewer.