-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean host fonts CSS when enabling/disabling CDN
- Loading branch information
1 parent
7f2f3ae
commit 1ca09d9
Showing
2 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,11 +50,7 @@ public function clean_css_fonts() { | |
* @return void | ||
*/ | ||
public function clean_on_option_change( $old_value, $value ) { | ||
if ( ! isset( $old_value['host_fonts_locally'], $value['host_fonts_locally'] ) ) { | ||
return; | ||
} | ||
|
||
if ( $old_value['host_fonts_locally'] === $value['host_fonts_locally'] ) { | ||
if ( ! $this->did_setting_change( 'host_fonts_locally', $old_value, $value ) ) { | ||
return; | ||
} | ||
|
||
|
@@ -67,4 +63,44 @@ public function clean_on_option_change( $old_value, $value ) { | |
*/ | ||
do_action( 'rocket_host_fonts_locally_changed' ); | ||
} | ||
|
||
/** | ||
* Clean CSS & fonts files stored locally on CDN change | ||
* | ||
* @param mixed $old_value Old option value. | ||
* @param mixed $value New option value. | ||
* | ||
* @return void | ||
*/ | ||
public function clean_on_cdn_change( $old_value, $value ) { | ||
if ( ! $this->did_setting_change( 'cdn', $old_value, $value ) ) { | ||
return; | ||
} | ||
|
||
if ( ! $this->did_setting_change( 'cdn_cnames', $old_value, $value ) ) { | ||
return; | ||
} | ||
|
||
$this->clean_css_fonts(); | ||
} | ||
|
||
/** | ||
* Checks if the given setting's value changed. | ||
* | ||
* @param string $setting The settings's value to check in the old and new values. | ||
* @param mixed $old_value Old option value. | ||
* @param mixed $value New option value. | ||
* | ||
* @return bool | ||
*/ | ||
private function did_setting_change( $setting, array $old_value, array $value ) { | ||
Check failure on line 96 in inc/Engine/Media/Fonts/Clean/Clean.php GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.
Check failure on line 96 in inc/Engine/Media/Fonts/Clean/Clean.php GitHub Actions / WPRocket lint with PHP Stan. PHP 8.2 on ubuntu-latest.
|
||
return ( | ||
array_key_exists( $setting, $old_value ) | ||
&& | ||
array_key_exists( $setting, $value ) | ||
&& | ||
// phpcs:ignore Universal.Operators.StrictComparisons.LooseNotEqual | ||
$old_value[ $setting ] != $value[ $setting ] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters