diff --git a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php index 9a46c3cbcb..4540404392 100644 --- a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php +++ b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php @@ -95,7 +95,7 @@ public function maybe_apply_optimizations( string $html ): string { * @return string The modified HTML content with the beacon script injected just before the closing body tag. */ private function inject_beacon( $html, $url, $is_mobile ): string { - if ( rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) ) { + if ( rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) && empty( $_GET['wpr_imagedimensions'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return $html; } diff --git a/tests/Fixtures/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php b/tests/Fixtures/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php index bd18707c7d..3571658985 100644 --- a/tests/Fixtures/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php +++ b/tests/Fixtures/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php @@ -71,6 +71,7 @@ 'shouldReturnOriginalWhenDonotoptimize' => [ 'config' => [ 'donotrocketoptimize' => true, + 'sass_visit' => false, 'html' => $html_input, 'atf' => [ 'row' => null, @@ -81,6 +82,20 @@ ], 'expected' => $html_input, ], + 'shouldAddBeaconWhenDonotoptimizeAndSaaSVisit' => [ + 'config' => [ + 'donotrocketoptimize' => true, + 'sass_visit' => true, + 'html' => $html_input, + 'atf' => [ + 'row' => null, + ], + 'lrc' => [ + 'row' => null, + ], + ], + 'expected' => $html_output_with_beacon, + ], 'shouldAddBeaconToPage' => [ 'config' => [ 'html' => $html_input, diff --git a/tests/Integration/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php b/tests/Integration/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php index 6b69955ce7..a456930769 100644 --- a/tests/Integration/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php +++ b/tests/Integration/inc/Engine/Common/PerformanceHints/Frontend/Subscriber/maybe_apply_optimizations.php @@ -62,6 +62,10 @@ public function testShouldReturnAsExpected( $config, $expected ) { $_GET[ $config['query_string'] ] = 1; } + if ( isset( $config['sass_visit'] ) ) { + $_GET[ 'wpr_imagedimensions' ] = $config['sass_visit']; + } + if ( ! empty( $config['atf']['row'] ) ) { self::addLcp( $config['atf']['row'] ); }