Skip to content

Commit

Permalink
Merge branch 'develop' into fix/donnot-cache-and-optimize-not-valid-t…
Browse files Browse the repository at this point in the history
…axonomy-pages
  • Loading branch information
wordpressfan committed Oct 16, 2024
2 parents 5e577cb + 8b46e6b commit 8cabc3f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions inc/Engine/CDN/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function __construct( Options_Data $options, CDN $cdn ) {
public static function get_subscribed_events() {
return [
'rocket_buffer' => [
[ 'rewrite', 20 ],
[ 'rewrite_srcset', 21 ],
[ 'rewrite', 2 ],
[ 'rewrite_srcset', 3 ],
],
'rocket_css_content' => 'rewrite_css_properties',
'rocket_usedcss_content' => 'rewrite_css_properties',
Expand Down
4 changes: 4 additions & 0 deletions inc/Engine/Common/PerformanceHints/Frontend/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ 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' ) ) {
return $html;
}

$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';

if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'wpr-beacon' . $min . '.js' ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@
],
'expected' => $html_input,
],
'shouldReturnOriginalWhenDonotoptimize' => [
'config' => [
'donotrocketoptimize' => true,
'html' => $html_input,
'atf' => [
'row' => null,
],
'lrc' => [
'row' => null,
],
],
'expected' => $html_input,
],
'shouldAddBeaconToPage' => [
'config' => [
'html' => $html_input,
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/inc/Engine/CDN/Subscriber/rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Test_Rewrite extends TestCase {
public function set_up() {
parent::set_up();

$this->unregisterAllCallbacksExcept( 'rocket_buffer', 'rewrite', 20 );
$this->unregisterAllCallbacksExcept( 'rocket_buffer', 'rewrite', 2 );
}

public function tear_down() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function tear_down() {
public function testShouldReturnAsExpected( $config, $expected ) {
$this->config = $config;
$this->cached_user = $config['user_cache_enabled'] ?? false;
$this->donotrocketoptimize = $config['donotrocketoptimize'] ?? null;

if ( isset( $config['query_string'] ) ) {
$_GET[ $config['query_string'] ] = 1;
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.17.1-alpha1
* Version: 3.17.1
* 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.17.1-alpha1' );
define( 'WP_ROCKET_VERSION', '3.17.1' );
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 8cabc3f

Please sign in to comment.