Skip to content

Commit

Permalink
Release 3.18.1.3 (#7268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal authored Jan 31, 2025
1 parent 0a7bc8f commit 10e4ea7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
10 changes: 8 additions & 2 deletions inc/Engine/Common/PerformanceHints/Frontend/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ private function inject_beacon( $html, $url, $is_mobile ): string {
// Create the script tag.
$script_tag = "<script data-name=\"wpr-wpr-beacon\" src='{$script_url}' async></script>"; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
$last_body_tag_position = strrpos( $html, '</body>' );
// Append the script tag just before the last closing body tag especially in cases where there's an iframe.
$html = substr_replace( $html, $inline_script . $script_tag . '</body>', $last_body_tag_position, 7 );

if ( false !== $last_body_tag_position ) {
// Append the script tag just before the last closing body tag especially in cases where there's an iframe.
$html = substr_replace( $html, $inline_script . $script_tag . '</body>', $last_body_tag_position, 7 );
} else {
// Append to the end of html if </body> is not found.
$html .= $inline_script . $script_tag;
}

return $html;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head>
<title>Test</title>
</head>
<body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
<title>Test</title>
</head>
<body>
</html>
<script>var rocket_beacon_data = {"ajax_url":"http:\/\/example.org\/wp-admin\/admin-ajax.php","nonce":"96ac96b69e","url":"http:\/\/example.org","is_mobile":false,"width_threshold":1600,"height_threshold":700,"delay":500,"debug":false,"status":{"atf":true,"lrc":true},"elements":"img, video, picture, p, main, div, li, svg, section, header, span","lrc_threshold":1800}</script><script data-name="wpr-wpr-beacon" src='http://example.org/wp-content/plugins/wp-rocket/assets/js/wpr-beacon.min.js' async></script>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

$html_input = file_get_contents(__DIR__ . '/HTML/input.html');
$html_input_without_closing_body_tag = file_get_contents(__DIR__ . '/HTML/no_closing_body_tag_input.html');
$html_input_without_closing_body_tag_output = file_get_contents(__DIR__ . '/HTML/no_closing_body_tag_output.html');
$html_with_double_body = file_get_contents(__DIR__ . '/HTML/double_body_tag.html');
$html_with_double_body_output = file_get_contents(__DIR__ . '/HTML/output_double_body_tag.html');
$html_output = file_get_contents(__DIR__ . '/HTML/output.html');
Expand Down Expand Up @@ -629,5 +631,17 @@
],
'expected' => $html_with_double_body_output,
],
'shouldAddBeaconWithoutClosingBodyTag' => [
'config' => [
'html' => $html_input_without_closing_body_tag,
'atf' => [
'row' => null,
],
'lrc' => [
'row' => null,
],
],
'expected' => $html_input_without_closing_body_tag_output,
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public function testShouldReturnAsExpected( $config, $expected ) {
add_filter( 'pre_get_rocket_option_cache_logged_user', [ $this, 'get_cache_user' ] );

$this->assertSame(
$expected,
apply_filters( 'rocket_buffer', $config['html'] )
trim($expected),
trim(apply_filters( 'rocket_buffer', $config['html'] ))
);
}

Expand Down
4 changes: 2 additions & 2 deletions wp-rocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Rocket
* Plugin URI: https://wp-rocket.me
* Description: The best WordPress performance plugin.
* Version: 3.18.1.2
* Version: 3.18.1.3
* Requires at least: 5.8
* Requires PHP: 7.3
* Code Name: Iego
Expand All @@ -20,7 +20,7 @@
defined( 'ABSPATH' ) || exit;

// Rocket defines.
define( 'WP_ROCKET_VERSION', '3.18.1.2' );
define( 'WP_ROCKET_VERSION', '3.18.1.3' );
define( 'WP_ROCKET_WP_VERSION', '5.8' );
define( 'WP_ROCKET_WP_VERSION_TESTED', '6.3.1' );
define( 'WP_ROCKET_PHP_VERSION', '7.3' );
Expand Down

0 comments on commit 10e4ea7

Please sign in to comment.