Plugin Directory

Changeset 3737190


Ignore:
Timestamp:
10/09/2026 06:29:07 PM (2 weeks ago)
Author:
christos70
Message:

Update to version 1.0.4 from GitHub

Location:
sizemint-size-chart
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sizemint-size-chart/tags/1.0.4/admin/js/fit-finder-admin.js

    r3724648 r3737190  
    3434        /** @param {number} inches @return {number} */
    3535        function roundToNearestIn( inches ) {
    36                 // A tiny epsilon added before rounding, specifically here and
    37                 // not in roundToNearestCm: 0.5 (the cm grid increment) is
    38                 // exactly representable in binary floating point, so
    39                 // cm/0.5 never lands ambiguously close to a halfway point.
    40                 // 0.2 (the inch grid increment) is not, so inches/0.2 can
    41                 // produce a value like 1.4999999999999998 for a genuinely
    42                 // exact halfway input (0.3) -- verified to be the IDENTICAL
    43                 // underlying double PHP's round_to_grid() computes for the
    44                 // same input. PHP's round() applies its own documented
    45                 // pre-rounding correction there and resolves it to 2; JS's
    46                 // Math.round() has no such correction and resolves the same
    47                 // bit pattern to 1. Verified directly (not assumed) that
    48                 // PHP's output is unaffected by this same epsilon (0 of 3000
    49                 // sampled values change) — PHP was already correct, so only
    50                 // JS needs this correction to match its own documented
    51                 // contract as an equivalent, authoritative backstop.
    52                 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100;
     36                // Inches use a 0.2in grid, represented as 20 hundredths.
     37                // Normalize to hundredths first so rounding is stable across
     38                // PHP versions and agrees with the storefront's half-up rule.
     39                var hundredths = Math.round( Math.abs( inches ) * 100 );
     40                var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20;
     41                return ( inches < 0 ? -snapped : snapped ) / 100;
    5342        }
    5443
  • sizemint-size-chart/tags/1.0.4/includes/class-sizemint-fit-finder-data.php

    r3724648 r3737190  
    7171         */
    7272        public static function round_to_grid( $value, $unit ) {
    73                 $increment = ( 'in' === $unit ) ? 0.2 : 0.5;
    74                 return round( round( $value / $increment ) * $increment, 2 );
     73                // Normalize to hundredths first, then snap using integer
     74                // hundredths. This gives PHP 7.4 through 8.4 the same
     75                // half-up result without depending on float division by 0.2.
     76                $grid_hundredths = ( 'in' === $unit ) ? 20 : 50;
     77                $hundredths      = (int) floor( abs( (float) $value ) * 100 + 0.5 );
     78                $snapped         = (int) ( floor( ( $hundredths + ( $grid_hundredths / 2 ) ) / $grid_hundredths ) * $grid_hundredths );
     79                $sign            = ( (float) $value < 0 ) ? -1 : 1;
     80
     81                return (float) ( ( $sign * $snapped ) / 100 );
    7582        }
    7683
  • sizemint-size-chart/tags/1.0.4/public/js/fit-finder.js

    r3724648 r3737190  
    309309        /** @param {number} inches @return {number} */
    310310        function roundToNearestIn( inches ) {
    311                 // A tiny epsilon added before rounding, specifically here and
    312                 // not in roundToNearestCm: 0.5 (the cm grid increment) is
    313                 // exactly representable in binary floating point, so
    314                 // cm/0.5 never lands ambiguously close to a halfway point.
    315                 // 0.2 (the inch grid increment) is not, so inches/0.2 can
    316                 // produce a value like 1.4999999999999998 for a genuinely
    317                 // exact halfway input (0.3) -- verified to be the IDENTICAL
    318                 // underlying double PHP's round_to_grid() computes for the
    319                 // same input. PHP's round() applies its own documented
    320                 // pre-rounding correction there and resolves it to 2; JS's
    321                 // Math.round() has no such correction and resolves the same
    322                 // bit pattern to 1. Verified directly (not assumed) that
    323                 // PHP's output is unaffected by this same epsilon (0 of 3000
    324                 // sampled values change) — PHP was already correct, so only
    325                 // JS needs this correction to match its own documented
    326                 // contract as an equivalent, authoritative backstop.
    327                 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100;
     311                // Inches use a 0.2in grid, represented as 20 hundredths.
     312                // Normalize to hundredths first so rounding is stable across
     313                // PHP versions and agrees with the storefront's half-up rule.
     314                var hundredths = Math.round( Math.abs( inches ) * 100 );
     315                var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20;
     316                return ( inches < 0 ? -snapped : snapped ) / 100;
    328317        }
    329318
  • sizemint-size-chart/tags/1.0.4/readme.txt

    r3729159 r3737190  
    66Requires PHP: 7.4
    77WC tested up to: 11.1
    8 Stable tag: 1.0.3
     8Stable tag: 1.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    4545== Changelog ==
    4646
     47= 1.0.4 =
     48* Fixed: Fit Finder inch measurements now round consistently across supported PHP versions, including exact halfway values.
     49
    4750= 1.0.3 =
    4851* Fixed: a Size Chart linked to a valid Fit Finder table can now be published and displayed even when the chart's own rows are empty. A valid linked Fit Finder table takes precedence; if the link is later removed or becomes invalid, the chart falls back to its own stored rows, which are preserved while linked.
  • sizemint-size-chart/tags/1.0.4/sizemint.php

    r3729159 r3737190  
    44 * Plugin URI:        https://sizemint.com/
    55 * Description:       A reliable, lightweight size chart plugin for WooCommerce. Core features are, and will always be free.
    6  * Version:           1.0.3
     6 * Version:           1.0.4
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    2121}
    2222
    23 define( 'SIZEMINT_VERSION', '1.0.3' );
     23define( 'SIZEMINT_VERSION', '1.0.4' );
    2424define( 'SIZEMINT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2525define( 'SIZEMINT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • sizemint-size-chart/trunk/admin/js/fit-finder-admin.js

    r3724648 r3737190  
    3434        /** @param {number} inches @return {number} */
    3535        function roundToNearestIn( inches ) {
    36                 // A tiny epsilon added before rounding, specifically here and
    37                 // not in roundToNearestCm: 0.5 (the cm grid increment) is
    38                 // exactly representable in binary floating point, so
    39                 // cm/0.5 never lands ambiguously close to a halfway point.
    40                 // 0.2 (the inch grid increment) is not, so inches/0.2 can
    41                 // produce a value like 1.4999999999999998 for a genuinely
    42                 // exact halfway input (0.3) -- verified to be the IDENTICAL
    43                 // underlying double PHP's round_to_grid() computes for the
    44                 // same input. PHP's round() applies its own documented
    45                 // pre-rounding correction there and resolves it to 2; JS's
    46                 // Math.round() has no such correction and resolves the same
    47                 // bit pattern to 1. Verified directly (not assumed) that
    48                 // PHP's output is unaffected by this same epsilon (0 of 3000
    49                 // sampled values change) — PHP was already correct, so only
    50                 // JS needs this correction to match its own documented
    51                 // contract as an equivalent, authoritative backstop.
    52                 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100;
     36                // Inches use a 0.2in grid, represented as 20 hundredths.
     37                // Normalize to hundredths first so rounding is stable across
     38                // PHP versions and agrees with the storefront's half-up rule.
     39                var hundredths = Math.round( Math.abs( inches ) * 100 );
     40                var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20;
     41                return ( inches < 0 ? -snapped : snapped ) / 100;
    5342        }
    5443
  • sizemint-size-chart/trunk/includes/class-sizemint-fit-finder-data.php

    r3724648 r3737190  
    7171         */
    7272        public static function round_to_grid( $value, $unit ) {
    73                 $increment = ( 'in' === $unit ) ? 0.2 : 0.5;
    74                 return round( round( $value / $increment ) * $increment, 2 );
     73                // Normalize to hundredths first, then snap using integer
     74                // hundredths. This gives PHP 7.4 through 8.4 the same
     75                // half-up result without depending on float division by 0.2.
     76                $grid_hundredths = ( 'in' === $unit ) ? 20 : 50;
     77                $hundredths      = (int) floor( abs( (float) $value ) * 100 + 0.5 );
     78                $snapped         = (int) ( floor( ( $hundredths + ( $grid_hundredths / 2 ) ) / $grid_hundredths ) * $grid_hundredths );
     79                $sign            = ( (float) $value < 0 ) ? -1 : 1;
     80
     81                return (float) ( ( $sign * $snapped ) / 100 );
    7582        }
    7683
  • sizemint-size-chart/trunk/public/js/fit-finder.js

    r3724648 r3737190  
    309309        /** @param {number} inches @return {number} */
    310310        function roundToNearestIn( inches ) {
    311                 // A tiny epsilon added before rounding, specifically here and
    312                 // not in roundToNearestCm: 0.5 (the cm grid increment) is
    313                 // exactly representable in binary floating point, so
    314                 // cm/0.5 never lands ambiguously close to a halfway point.
    315                 // 0.2 (the inch grid increment) is not, so inches/0.2 can
    316                 // produce a value like 1.4999999999999998 for a genuinely
    317                 // exact halfway input (0.3) -- verified to be the IDENTICAL
    318                 // underlying double PHP's round_to_grid() computes for the
    319                 // same input. PHP's round() applies its own documented
    320                 // pre-rounding correction there and resolves it to 2; JS's
    321                 // Math.round() has no such correction and resolves the same
    322                 // bit pattern to 1. Verified directly (not assumed) that
    323                 // PHP's output is unaffected by this same epsilon (0 of 3000
    324                 // sampled values change) — PHP was already correct, so only
    325                 // JS needs this correction to match its own documented
    326                 // contract as an equivalent, authoritative backstop.
    327                 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100;
     311                // Inches use a 0.2in grid, represented as 20 hundredths.
     312                // Normalize to hundredths first so rounding is stable across
     313                // PHP versions and agrees with the storefront's half-up rule.
     314                var hundredths = Math.round( Math.abs( inches ) * 100 );
     315                var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20;
     316                return ( inches < 0 ? -snapped : snapped ) / 100;
    328317        }
    329318
  • sizemint-size-chart/trunk/readme.txt

    r3729159 r3737190  
    66Requires PHP: 7.4
    77WC tested up to: 11.1
    8 Stable tag: 1.0.3
     8Stable tag: 1.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    4545== Changelog ==
    4646
     47= 1.0.4 =
     48* Fixed: Fit Finder inch measurements now round consistently across supported PHP versions, including exact halfway values.
     49
    4750= 1.0.3 =
    4851* Fixed: a Size Chart linked to a valid Fit Finder table can now be published and displayed even when the chart's own rows are empty. A valid linked Fit Finder table takes precedence; if the link is later removed or becomes invalid, the chart falls back to its own stored rows, which are preserved while linked.
  • sizemint-size-chart/trunk/sizemint.php

    r3729159 r3737190  
    44 * Plugin URI:        https://sizemint.com/
    55 * Description:       A reliable, lightweight size chart plugin for WooCommerce. Core features are, and will always be free.
    6  * Version:           1.0.3
     6 * Version:           1.0.4
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    2121}
    2222
    23 define( 'SIZEMINT_VERSION', '1.0.3' );
     23define( 'SIZEMINT_VERSION', '1.0.4' );
    2424define( 'SIZEMINT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2525define( 'SIZEMINT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.