-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
222 additions
and
45 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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
/** | ||
* Rocket Cache Settings class. | ||
* | ||
* @package EightshiftForms\Misc | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace EightshiftForms\Misc; | ||
|
||
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; | ||
use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; | ||
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; | ||
use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; | ||
|
||
/** | ||
* SettingsRocketCache class. | ||
*/ | ||
class SettingsRocketCache implements UtilsSettingGlobalInterface, ServiceInterface | ||
{ | ||
/** | ||
* Filter global settings key. | ||
*/ | ||
public const FILTER_SETTINGS_GLOBAL_NAME = 'es_forms_settings_global_rocket_cache'; | ||
|
||
/** | ||
* Filter settings is Valid key. | ||
*/ | ||
public const FILTER_SETTINGS_IS_VALID_NAME = 'es_forms_settings_is_valid_rocket_cache'; | ||
|
||
/** | ||
* Settings key. | ||
*/ | ||
public const SETTINGS_TYPE_KEY = 'rocket-cache'; | ||
|
||
/** | ||
* Rocket cache use key. | ||
*/ | ||
public const SETTINGS_ROCKET_CACHE_USE_KEY = 'rocket-cache-use'; | ||
|
||
/** | ||
* Register all the hooks. | ||
* | ||
* @return void | ||
*/ | ||
public function register(): void | ||
{ | ||
\add_filter(self::FILTER_SETTINGS_GLOBAL_NAME, [$this, 'getSettingsGlobalData']); | ||
\add_filter(self::FILTER_SETTINGS_IS_VALID_NAME, [$this, 'isSettingsGlobalValid']); | ||
} | ||
|
||
/** | ||
* Determine if settings global are valid. | ||
* | ||
* @return boolean | ||
*/ | ||
public function isSettingsGlobalValid(): bool | ||
{ | ||
$isUsed = UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_ROCKET_CACHE_USE_KEY, self::SETTINGS_ROCKET_CACHE_USE_KEY); | ||
|
||
if (!$isUsed) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Get global settings array for building settings page. | ||
* | ||
* @return array<int, array<string, mixed>> | ||
*/ | ||
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'), | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.