From e4117027b5efefe8af085fc0bdf84859cac6d272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 4 Jun 2024 19:25:11 +0200 Subject: [PATCH 1/4] adding additional options for caching --- composer.lock | 16 +-- src/Cache/SettingsCache.php | 46 ++++++-- src/Hooks/Filters.php | 3 + src/Hooks/FiltersSettingsBuilder.php | 10 ++ src/Misc/SettingsCloudflare.php | 2 +- src/Misc/SettingsRocketCache.php | 101 ++++++++++++++++++ src/Misc/SettingsWpml.php | 2 +- src/Rest/Routes/Settings/CacheDeleteRoute.php | 78 +++++++++----- 8 files changed, 213 insertions(+), 45 deletions(-) create mode 100644 src/Misc/SettingsRocketCache.php diff --git a/composer.lock b/composer.lock index 6914b4279..df5180ebe 100644 --- a/composer.lock +++ b/composer.lock @@ -62,12 +62,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "aee4e5cab817a4850934bc3e4d6e94693089965e" + "reference": "836e1118704d5b7c245d76bc640fc9b409be2301" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/aee4e5cab817a4850934bc3e4d6e94693089965e", - "reference": "aee4e5cab817a4850934bc3e4d6e94693089965e", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/836e1118704d5b7c245d76bc640fc9b409be2301", + "reference": "836e1118704d5b7c245d76bc640fc9b409be2301", "shasum": "" }, "require": { @@ -121,7 +121,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-05-21T12:54:55+00:00" + "time": "2024-06-04T15:49:32+00:00" }, { "name": "infinum/eightshift-libs", @@ -129,12 +129,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-libs.git", - "reference": "38b2a3f188ec2533e6b671fc8ac08681602628c1" + "reference": "8c304301af5c67163b896f79ab4c98f616c54d8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-libs/zipball/38b2a3f188ec2533e6b671fc8ac08681602628c1", - "reference": "38b2a3f188ec2533e6b671fc8ac08681602628c1", + "url": "https://api.github.com/repos/infinum/eightshift-libs/zipball/8c304301af5c67163b896f79ab4c98f616c54d8c", + "reference": "8c304301af5c67163b896f79ab4c98f616c54d8c", "shasum": "" }, "require": { @@ -188,7 +188,7 @@ "issues": "https://github.com/infinum/eightshift-libs/issues", "source": "https://github.com/infinum/eightshift-libs" }, - "time": "2024-05-20T11:34:29+00:00" + "time": "2024-06-04T15:08:52+00:00" }, { "name": "laravel/serializable-closure", diff --git a/src/Cache/SettingsCache.php b/src/Cache/SettingsCache.php index f6a57b478..deb7ab347 100644 --- a/src/Cache/SettingsCache.php +++ b/src/Cache/SettingsCache.php @@ -128,20 +128,32 @@ function ($key, $value) { 'component' => 'layout', 'layoutType' => 'layout-v-stack-clean', 'layoutContent' => [ - ...$outputIntegrations, [ - 'component' => 'divider', - 'dividerExtraVSpacing' => true, + 'component' => 'card-inline', + 'cardInlineTitle' => __('All operational cache', 'eightshift-forms'), + 'cardInlineSubTitle' => __('Delete all forms operational cache at once!', 'eightshift-forms'), + 'cardInlineIcon' => UtilsHelper::getUtilsIcons('allChecked'), + 'cardInlineRightContent' => [ + [ + 'component' => 'submit', + 'submitValue' => \__('Clear', 'eightshift-forms'), + 'submitVariant' => 'ghost', + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('cacheType') => 'allOperational', + UtilsHelper::getStateAttribute('reload') => 'false', + ], + 'additionalClass' => UtilsHelper::getStateSelectorAdmin('cacheDelete'), + ], + ], ], - ...$outputOther, [ 'component' => 'divider', 'dividerExtraVSpacing' => true, ], [ 'component' => 'card-inline', - 'cardInlineTitle' => 'All caches', - 'cardInlineSubTitle' => 'Use with caution!', + 'cardInlineTitle' => __('All internal cache', 'eightshift-forms'), + 'cardInlineSubTitle' => __('Delete all forms internal cache at once!', 'eightshift-forms'), 'cardInlineIcon' => UtilsHelper::getUtilsIcons('allChecked'), 'cardInlineRightContent' => [ [ @@ -149,7 +161,7 @@ function ($key, $value) { 'submitValue' => \__('Clear', 'eightshift-forms'), 'submitVariant' => 'ghost', 'submitAttrs' => [ - UtilsHelper::getStateAttribute('cacheType') => 'all', + UtilsHelper::getStateAttribute('cacheType') => 'allInteral', UtilsHelper::getStateAttribute('reload') => 'false', ], 'additionalClass' => UtilsHelper::getStateSelectorAdmin('cacheDelete'), @@ -158,6 +170,26 @@ function ($key, $value) { ], ] ], + [ + 'component' => 'intro', + 'introTitle' => __('Integration cache', 'eightshift-forms'), + 'introSubtitle' => __('Here you can clear individual cache for each integration.', 'eightshift-forms'), + ], + [ + 'component' => 'layout', + 'layoutType' => 'layout-v-stack-clean', + 'layoutContent' => $outputIntegrations, + ], + [ + 'component' => 'intro', + 'introTitle' => __('Operational cache', 'eightshift-forms'), + 'introSubtitle' => __('Here you can clear individual operational cache.', 'eightshift-forms'), + ], + [ + 'component' => 'layout', + 'layoutType' => 'layout-v-stack-clean', + 'layoutContent' => $outputOther, + ], ]; } } diff --git a/src/Hooks/Filters.php b/src/Hooks/Filters.php index e1d974437..727ddddc5 100644 --- a/src/Hooks/Filters.php +++ b/src/Hooks/Filters.php @@ -33,6 +33,7 @@ use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; use EightshiftForms\Misc\SettingsCloudflare; +use EightshiftForms\Misc\SettingsRocketCache; use EightshiftForms\Misc\SettingsWpml; use EightshiftForms\Security\SettingsSecurity; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; @@ -350,6 +351,8 @@ private static function getSettingsNoneTranslatableNames(): array SettingsWpml::SETTINGS_WPML_USE_KEY, + SettingsRocketCache::SETTINGS_ROCKET_CACHE_USE_KEY, + SettingsFallback::SETTINGS_FALLBACK_USE_KEY, SettingsMigration::SETTINGS_MIGRATION_USE_KEY, diff --git a/src/Hooks/FiltersSettingsBuilder.php b/src/Hooks/FiltersSettingsBuilder.php index 2df6dd3d2..6ab731900 100644 --- a/src/Hooks/FiltersSettingsBuilder.php +++ b/src/Hooks/FiltersSettingsBuilder.php @@ -58,6 +58,7 @@ use EightshiftForms\Integrations\Pipedrive\PipedriveClient; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; use EightshiftForms\Misc\SettingsCloudflare; +use EightshiftForms\Misc\SettingsRocketCache; use EightshiftForms\Misc\SettingsWpml; use EightshiftForms\Security\SettingsSecurity; use EightshiftForms\Validation\SettingsValidation; @@ -466,6 +467,15 @@ public function getSettingsFiltersData(): array 'desc' => \__('WPML is a WordPress plugin, which allows building and running multilingual sites. It integrates with almost all popular WordPress themes and plugins and allows building anything from multilingual blogs to complex e-commerce and corporate sites.', 'eightshift-forms'), ], ], + SettingsRocketCache::SETTINGS_TYPE_KEY => [ + 'settingsGlobal' => SettingsRocketCache::FILTER_SETTINGS_GLOBAL_NAME, + 'type' => UtilsConfig::SETTINGS_INTERNAL_TYPE_MISCELLANEOUS, + 'use' => SettingsRocketCache::SETTINGS_ROCKET_CACHE_USE_KEY, + 'labels' => [ + 'title' => \__('Rocket Cache', 'eightshift-forms'), + 'desc' => \__('WP Rocket cache is a WordPress plugin that speeds up your website by caching static content, minifying CSS and JavaScript, and optimizing images.', 'eightshift-forms'), + ], + ], SettingsCloudflare::SETTINGS_TYPE_KEY => [ 'settingsGlobal' => SettingsCloudflare::FILTER_SETTINGS_GLOBAL_NAME, 'type' => UtilsConfig::SETTINGS_INTERNAL_TYPE_MISCELLANEOUS, diff --git a/src/Misc/SettingsCloudflare.php b/src/Misc/SettingsCloudflare.php index 489a7c34b..59916ea7e 100644 --- a/src/Misc/SettingsCloudflare.php +++ b/src/Misc/SettingsCloudflare.php @@ -80,7 +80,7 @@ public function getSettingsGlobalData(): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - UtilsSettingsOutputHelper::getMiscDisclaimer(), + UtilsSettingsOutputHelper::getMiscDisclaimer(__('Cloudflare', 'eightshift-forms')), [ 'component' => 'intro', 'introTitle' => \__('Features affected by Cloudflare are:', 'eightshift-forms'), diff --git a/src/Misc/SettingsRocketCache.php b/src/Misc/SettingsRocketCache.php new file mode 100644 index 000000000..6e18a89aa --- /dev/null +++ b/src/Misc/SettingsRocketCache.php @@ -0,0 +1,101 @@ +> + */ + public function getSettingsGlobalData(): array + { + if (!UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_ROCKET_CACHE_USE_KEY, self::SETTINGS_ROCKET_CACHE_USE_KEY)) { + return UtilsSettingsOutputHelper::getNoActiveFeature(); + } + + return [ + UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), + UtilsSettingsOutputHelper::getMiscDisclaimer(__('WP Rocket Cache', 'eightshift-forms')), + [ + 'component' => 'intro', + 'introTitle' => \__('Features affected by WP Rocket cache are:', 'eightshift-forms'), + ], + [ + 'component' => 'layout', + 'layoutType' => 'layout-v-stack-card', + 'layoutContent' => [ + [ + 'component' => 'intro', + 'introTitle' => \__('Forms cache', 'eightshift-forms'), + 'introSubtitle' => \__('When you clear forms cache, you will also clear WP Rocket cache.', 'eightshift-forms'), + ], + ], + ], + ]; + } +} diff --git a/src/Misc/SettingsWpml.php b/src/Misc/SettingsWpml.php index c78919ea4..80b6ffafa 100644 --- a/src/Misc/SettingsWpml.php +++ b/src/Misc/SettingsWpml.php @@ -101,7 +101,7 @@ public function getSettingsGlobalData(): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - UtilsSettingsOutputHelper::getMiscDisclaimer(), + UtilsSettingsOutputHelper::getMiscDisclaimer(__('WPML', 'eightshift-forms')), [ 'component' => 'intro', 'introSubtitle' => \__('In order for Eightshift Forms to work correctly with WPML, you must enable translations in the WPML settings.', 'eightshift-forms'), diff --git a/src/Rest/Routes/Settings/CacheDeleteRoute.php b/src/Rest/Routes/Settings/CacheDeleteRoute.php index ecbdca9e1..22fcf2934 100644 --- a/src/Rest/Routes/Settings/CacheDeleteRoute.php +++ b/src/Rest/Routes/Settings/CacheDeleteRoute.php @@ -14,6 +14,7 @@ use EightshiftForms\Validation\ValidatorInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Rest\Routes\AbstractUtilsBaseRoute; +use EightshiftFormsVendor\EightshiftLibs\Cache\ManifestCacheInterface; use EightshiftFormsVendor\EightshiftLibs\Helpers\Helpers; use WP_REST_Request; @@ -29,15 +30,25 @@ class CacheDeleteRoute extends AbstractUtilsBaseRoute */ protected $validator; + /** + * Instance variable for listing data. + * + * @var ManifestCacheInterface + */ + protected $manifestCache; + /** * Create a new instance that injects classes * * @param ValidatorInterface $validator Inject validation methods. + * @param ManifestCacheInterface $manifestCache Inject manifest cache interface. */ public function __construct( - ValidatorInterface $validator + ValidatorInterface $validator, + ManifestCacheInterface $manifestCache ) { $this->validator = $validator; + $this->manifestCache = $manifestCache; } /** @@ -90,36 +101,47 @@ public function routeCallback(WP_REST_Request $request) $data = \apply_filters(UtilsConfig::FILTER_SETTINGS_DATA, []); - if ($type === 'all') { - $allItems = Helpers::flattenArray(\array_map( - static function ($item) { - if (isset($item['cache'])) { - return $item['cache']; + switch ($type) { + case 'allOperational': + $allItems = Helpers::flattenArray(\array_map( + static function ($item) { + if (isset($item['cache'])) { + return $item['cache']; + } + }, + $data + )); + + if ($allItems) { + foreach ($allItems as $item) { + \delete_transient($item); } - }, - $data - )); + } + + $outputTitle = \esc_html__('All operational', 'eightshift-forms'); + break; + case 'allInteral': + $outputTitle = \esc_html__('All internal', 'eightshift-forms'); + $this->manifestCache->deleteAllCache(); + break; + default: + $cacheTypes = $data[$type]['cache'] ?? []; + if (!$cacheTypes) { + return \rest_ensure_response( + UtilsApiHelper::getApiErrorPublicOutput( + \esc_html__('Provided cache type doesn\'t exist.', 'eightshift-forms'), + [], + $debug + ) + ); + } - if ($allItems) { - foreach ($allItems as $item) { + foreach ($cacheTypes as $item) { \delete_transient($item); } - } - } else { - $cacheTypes = $data[$type]['cache'] ?? []; - if (!$cacheTypes) { - return \rest_ensure_response( - UtilsApiHelper::getApiErrorPublicOutput( - \esc_html__('Provided cache type doesn\'t exist.', 'eightshift-forms'), - [], - $debug - ) - ); - } - - foreach ($cacheTypes as $item) { - \delete_transient($item); - } + + $outputTitle = \ucfirst($type); + break; } // Clear WP-Rocket cache if cache is cleared. @@ -131,7 +153,7 @@ static function ($item) { return \rest_ensure_response( UtilsApiHelper::getApiSuccessPublicOutput( // translators: %s will be replaced with the form type. - \sprintf(\esc_html__('%s cache deleted successfully!', 'eightshift-forms'), \ucfirst($type)), + \sprintf(\esc_html__('%s cache deleted successfully!', 'eightshift-forms'), $outputTitle), [], $debug ) From 9fe859fd1d02ebb9e662a5b70396673ad6df5dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 4 Jun 2024 19:36:23 +0200 Subject: [PATCH 2/4] adding additional options for caching --- src/AdminMenus/FormAdminMenu.php | 2 +- .../components/admin-settings/admin-settings.php | 1 - src/Cache/SettingsCache.php | 16 ++++++++-------- src/Misc/SettingsCloudflare.php | 2 +- src/Misc/SettingsRocketCache.php | 2 +- src/Misc/SettingsWpml.php | 2 +- src/Rest/Routes/Settings/CacheDeleteRoute.php | 5 +++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index 67bdc88a8..d63344e29 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -319,7 +319,7 @@ protected function processAttributes($attr): array */ private function getMultilangTitle(string $title): string { - $useWpml = \apply_filters(SettingsWpml::FILTER_SETTINGS_IS_VALID_NAME, []); + $useWpml = \apply_filters(SettingsWpml::FILTER_SETTINGS_IS_VALID_NAME, false); if ($useWpml) { $lang = \apply_filters('wpml_current_language', ''); if ($lang) { diff --git a/src/Blocks/components/admin-settings/admin-settings.php b/src/Blocks/components/admin-settings/admin-settings.php index d27a6f4a9..0aa700c48 100644 --- a/src/Blocks/components/admin-settings/admin-settings.php +++ b/src/Blocks/components/admin-settings/admin-settings.php @@ -70,7 +70,6 @@ [ [ 'component' => 'card-inline', - 'cardInlineTitle' => __('All operational cache', 'eightshift-forms'), - 'cardInlineSubTitle' => __('Delete all forms operational cache at once!', 'eightshift-forms'), + 'cardInlineTitle' => \__('All operational cache', 'eightshift-forms'), + 'cardInlineSubTitle' => \__('Delete all forms operational cache at once!', 'eightshift-forms'), 'cardInlineIcon' => UtilsHelper::getUtilsIcons('allChecked'), 'cardInlineRightContent' => [ [ @@ -152,8 +152,8 @@ function ($key, $value) { ], [ 'component' => 'card-inline', - 'cardInlineTitle' => __('All internal cache', 'eightshift-forms'), - 'cardInlineSubTitle' => __('Delete all forms internal cache at once!', 'eightshift-forms'), + 'cardInlineTitle' => \__('All internal cache', 'eightshift-forms'), + 'cardInlineSubTitle' => \__('Delete all forms internal cache at once!', 'eightshift-forms'), 'cardInlineIcon' => UtilsHelper::getUtilsIcons('allChecked'), 'cardInlineRightContent' => [ [ @@ -172,8 +172,8 @@ function ($key, $value) { ], [ 'component' => 'intro', - 'introTitle' => __('Integration cache', 'eightshift-forms'), - 'introSubtitle' => __('Here you can clear individual cache for each integration.', 'eightshift-forms'), + 'introTitle' => \__('Integration cache', 'eightshift-forms'), + 'introSubtitle' => \__('Here you can clear individual cache for each integration.', 'eightshift-forms'), ], [ 'component' => 'layout', @@ -182,8 +182,8 @@ function ($key, $value) { ], [ 'component' => 'intro', - 'introTitle' => __('Operational cache', 'eightshift-forms'), - 'introSubtitle' => __('Here you can clear individual operational cache.', 'eightshift-forms'), + 'introTitle' => \__('Operational cache', 'eightshift-forms'), + 'introSubtitle' => \__('Here you can clear individual operational cache.', 'eightshift-forms'), ], [ 'component' => 'layout', diff --git a/src/Misc/SettingsCloudflare.php b/src/Misc/SettingsCloudflare.php index 59916ea7e..8b608c113 100644 --- a/src/Misc/SettingsCloudflare.php +++ b/src/Misc/SettingsCloudflare.php @@ -80,7 +80,7 @@ public function getSettingsGlobalData(): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - UtilsSettingsOutputHelper::getMiscDisclaimer(__('Cloudflare', 'eightshift-forms')), + UtilsSettingsOutputHelper::getMiscDisclaimer(\__('Cloudflare', 'eightshift-forms')), [ 'component' => 'intro', 'introTitle' => \__('Features affected by Cloudflare are:', 'eightshift-forms'), diff --git a/src/Misc/SettingsRocketCache.php b/src/Misc/SettingsRocketCache.php index 6e18a89aa..886d1cc72 100644 --- a/src/Misc/SettingsRocketCache.php +++ b/src/Misc/SettingsRocketCache.php @@ -80,7 +80,7 @@ public function getSettingsGlobalData(): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - UtilsSettingsOutputHelper::getMiscDisclaimer(__('WP Rocket Cache', 'eightshift-forms')), + UtilsSettingsOutputHelper::getMiscDisclaimer(\__('WP Rocket Cache', 'eightshift-forms')), [ 'component' => 'intro', 'introTitle' => \__('Features affected by WP Rocket cache are:', 'eightshift-forms'), diff --git a/src/Misc/SettingsWpml.php b/src/Misc/SettingsWpml.php index 80b6ffafa..ac581e09e 100644 --- a/src/Misc/SettingsWpml.php +++ b/src/Misc/SettingsWpml.php @@ -101,7 +101,7 @@ public function getSettingsGlobalData(): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - UtilsSettingsOutputHelper::getMiscDisclaimer(__('WPML', 'eightshift-forms')), + UtilsSettingsOutputHelper::getMiscDisclaimer(\__('WPML', 'eightshift-forms')), [ 'component' => 'intro', 'introSubtitle' => \__('In order for Eightshift Forms to work correctly with WPML, you must enable translations in the WPML settings.', 'eightshift-forms'), diff --git a/src/Rest/Routes/Settings/CacheDeleteRoute.php b/src/Rest/Routes/Settings/CacheDeleteRoute.php index 22fcf2934..c6ca01c4a 100644 --- a/src/Rest/Routes/Settings/CacheDeleteRoute.php +++ b/src/Rest/Routes/Settings/CacheDeleteRoute.php @@ -10,6 +10,7 @@ namespace EightshiftForms\Rest\Routes\Settings; +use EightshiftForms\Misc\SettingsRocketCache; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsApiHelper; use EightshiftForms\Validation\ValidatorInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; @@ -111,7 +112,7 @@ static function ($item) { }, $data )); - + if ($allItems) { foreach ($allItems as $item) { \delete_transient($item); @@ -145,7 +146,7 @@ static function ($item) { } // Clear WP-Rocket cache if cache is cleared. - if (\function_exists('rocket_clean_domain')) { + if (\function_exists('rocket_clean_domain') && \apply_filters(SettingsRocketCache::FILTER_SETTINGS_IS_VALID_NAME, false)) { \rocket_clean_domain(); } From e7b686f507f8dba4224971ee208070c1522fe1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 4 Jun 2024 19:36:59 +0200 Subject: [PATCH 3/4] adding additional options for caching --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d19020766..331e87768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - `src/Exception/MissingFilterInfoException.php` because it is not used anymore. ### Added -- New `Caching` service for manifest data. +- New `Caching` service for manifest data and new options to flush cache from the settings. - Input number validation for allowed keys. ### Fixed From cee409fa3317356f07eb78bd579887c4a3602217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 4 Jun 2024 20:00:39 +0200 Subject: [PATCH 4/4] adding additional options for caching --- CHANGELOG.md | 1 + src/Blocks/components/form/assets/enrichment.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 331e87768..e7ea536c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a ### Added - New `Caching` service for manifest data and new options to flush cache from the settings. - Input number validation for allowed keys. +- WP Rocket cache options settings. ### Fixed - Custom post type labels are not translatable. diff --git a/src/Blocks/components/form/assets/enrichment.js b/src/Blocks/components/form/assets/enrichment.js index 92ec62001..e3e56f04d 100644 --- a/src/Blocks/components/form/assets/enrichment.js +++ b/src/Blocks/components/form/assets/enrichment.js @@ -147,7 +147,7 @@ export class Enrichment { return; } - if (!newStorage) { + if (!localStorage || !newStorage) { return; } @@ -228,6 +228,10 @@ export class Enrichment { return null; } + if (!localStorage) { + return null; + } + return localStorage?.getItem(storageName); } @@ -243,6 +247,10 @@ export class Enrichment { return; } + if (!localStorage) { + return; + } + localStorage?.removeItem(storageName); }