Skip to content

Commit

Permalink
Merge pull request #96 from xwp/fix/80-allow-smaller-tracking-ratio
Browse files Browse the repository at this point in the history
Add support for web vitals ratio upto 0.001.
  • Loading branch information
bharatpareek authored Mar 6, 2023
2 parents bf14bce + 83d8543 commit db1e669
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ All contributions are welcome! Please create [an issue](https://github.com/xwp/s
#### 1.3 - February 24th, 2023

- Added INP metric.
- Support for smaller web vitals ratio.

#### 1.2 - December 5, 2022

Expand Down
2 changes: 1 addition & 1 deletion php/src/class-webvitalstrackingratiofield.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function render() {
$display_theme_override_warning = true;
}
?>
<input type='number' name='spt_settings[<?php echo esc_attr( self::OPTION_WEB_VITALS_TRACKING_RATIO ); ?>]' step='0.01' min='0.01' max='1'
<input type='number' name='spt_settings[<?php echo esc_attr( self::OPTION_WEB_VITALS_TRACKING_RATIO ); ?>]' step='0.001' min='0.001' max='1'
value='<?php echo esc_attr( $options[ self::OPTION_WEB_VITALS_TRACKING_RATIO ] ); ?>'
placeholder="<?php _e( 'Enter between 0 > 1', 'site-performance-tracker' ); ?>" aria-label="<?php _e( 'web vitals tracking ratio', 'site-performance-tracker' ); ?>"
<?php if ( $display_theme_override_warning ) { ?>
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/class-test-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public function test_web_vitals_tracking_ratio_render__empty_options() {
ob_end_clean();

$expected_html = <<<EOD
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.01' min='0.01' max='1'
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.001' min='0.001' max='1'
value='1'
placeholder="Enter between 0 > 1" aria-label="web vitals tracking ratio"
>
Expand All @@ -720,7 +720,7 @@ public function test_web_vitals_tracking_ratio_render__set_web_vitals_tracking_r
ob_end_clean();

$expected_html = <<<EOD
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.01' min='0.01' max='1'
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.001' min='0.001' max='1'
value='0.05'
placeholder="Enter between 0 > 1" aria-label="web vitals tracking ratio"
>
Expand All @@ -741,7 +741,7 @@ public function test_web_vitals_tracking_ratio_render__theme_web_vitals_tracking
ob_end_clean();

$expected_html = <<<EOD
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.01' min='0.01' max='1'
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.001' min='0.001' max='1'
value='0.33'
placeholder="Enter between 0 > 1" aria-label="web vitals tracking ratio"
readonly
Expand All @@ -768,7 +768,7 @@ function () {
ob_end_clean();

$expected_html = <<<EOD
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.01' min='0.01' max='1'
<input type='number' name='spt_settings[web_vitals_tracking_ratio]' step='0.001' min='0.001' max='1'
value='0.77'
placeholder="Enter between 0 > 1" aria-label="web vitals tracking ratio"
readonly
Expand Down

0 comments on commit db1e669

Please sign in to comment.