From 92330e8bd803d05e696f06e21a5085e2cc90e4be Mon Sep 17 00:00:00 2001 From: mostafa-hisham Date: Thu, 31 Aug 2023 19:44:18 +0300 Subject: [PATCH] fix truncate rucss on wp-rocket options changes (#6122) --- inc/Engine/Admin/DomainChange/Subscriber.php | 2 +- inc/Engine/Optimization/RUCSS/Admin/Subscriber.php | 2 +- inc/Engine/Preload/Admin/Subscriber.php | 13 +++++++------ .../Subscriber/maybeCleanCacheDomainChange.php | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/inc/Engine/Admin/DomainChange/Subscriber.php b/inc/Engine/Admin/DomainChange/Subscriber.php index 2f5cfdcc5e..3ecaee764d 100644 --- a/inc/Engine/Admin/DomainChange/Subscriber.php +++ b/inc/Engine/Admin/DomainChange/Subscriber.php @@ -112,7 +112,7 @@ public function maybe_clean_cache_domain_change() { * * @param array $value An array of submitted values for the settings. */ - do_action( 'rocket_options_changed', $options ); + do_action( 'rocket_domain_options_changed', $options ); } /** diff --git a/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php b/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php index 1b3d027a75..c697ec1915 100644 --- a/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php +++ b/inc/Engine/Optimization/RUCSS/Admin/Subscriber.php @@ -73,7 +73,7 @@ public static function get_subscribed_events() : array { ], 'switch_theme' => 'truncate_used_css', 'permalink_structure_changed' => 'truncate_used_css', - 'rocket_options_changed' => 'truncate_used_css', + 'rocket_domain_options_changed' => 'truncate_used_css', 'wp_trash_post' => 'delete_used_css_on_update_or_delete', 'delete_post' => 'delete_used_css_on_update_or_delete', 'clean_post_cache' => 'delete_used_css_on_update_or_delete', diff --git a/inc/Engine/Preload/Admin/Subscriber.php b/inc/Engine/Preload/Admin/Subscriber.php index 38e0c4a2b4..385ddfafb7 100644 --- a/inc/Engine/Preload/Admin/Subscriber.php +++ b/inc/Engine/Preload/Admin/Subscriber.php @@ -44,14 +44,15 @@ public function __construct( Options_Data $options, Settings $settings ) { */ public static function get_subscribed_events() { return [ - 'admin_notices' => [ + 'admin_notices' => [ [ 'maybe_display_preload_notice' ], ], - 'rocket_options_changed' => 'preload_homepage', - 'switch_theme' => 'preload_homepage', - 'rocket_after_clean_used_css' => 'preload_homepage', - 'rocket_input_sanitize' => 'sanitize_options', - 'wp_rocket_upgrade' => [ 'maybe_clean_cron', 15, 2 ], + 'rocket_options_changed' => 'preload_homepage', + 'switch_theme' => 'preload_homepage', + 'rocket_after_clean_used_css' => 'preload_homepage', + 'rocket_domain_options_changed' => 'preload_homepage', + 'rocket_input_sanitize' => 'sanitize_options', + 'wp_rocket_upgrade' => [ 'maybe_clean_cron', 15, 2 ], ]; } diff --git a/tests/Unit/inc/Engine/Admin/DomainChange/Subscriber/maybeCleanCacheDomainChange.php b/tests/Unit/inc/Engine/Admin/DomainChange/Subscriber/maybeCleanCacheDomainChange.php index 270a7b0c23..07be8860fc 100644 --- a/tests/Unit/inc/Engine/Admin/DomainChange/Subscriber/maybeCleanCacheDomainChange.php +++ b/tests/Unit/inc/Engine/Admin/DomainChange/Subscriber/maybeCleanCacheDomainChange.php @@ -54,7 +54,7 @@ public function testShouldDoAsExpected( $config ) Filters\expectApplied('rocket_configurations_changed')->andReturn($config['rocket_configurations_changed']); if($config['options'] && ! $config['rocket_configurations_changed']) { - Actions\expectDone('rocket_options_changed'); + Actions\expectDone('rocket_domain_options_changed'); } $this->subscriber->maybe_clean_cache_domain_change();