Skip to content

Commit

Permalink
release 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jun 5, 2024
2 parents fc0f831 + cee409f commit e6ebd77
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 45 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ 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.
- WP Rocket cache options settings.

### Fixed
- Custom post type labels are not translatable.
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
},
"devDependencies": {
"husky": "^9.0.11",
"webpack": "^5.90.2",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@eightshift/frontend-libs": "https://github.com/infinum/eightshift-frontend-libs.git#develop",
"@eightshift/frontend-libs": "^12.0.0",
"autosize": "^6.0.1",
"choices.js": "^10.2.0",
"dropzone": "^6.0.0-beta.2",
"flatpickr": "^4.6.13",
"reactflow": "^11.10.4"
"reactflow": "^11.11.3"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/AdminMenus/FormAdminMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/Blocks/components/admin-settings/admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@

<?php
// phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
echo $componentName;
echo Helpers::render(
'sidebar-section',
[
Expand Down
10 changes: 9 additions & 1 deletion src/Blocks/components/form/assets/enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Enrichment {
return;
}

if (!newStorage) {
if (!localStorage || !newStorage) {
return;
}

Expand Down Expand Up @@ -228,6 +228,10 @@ export class Enrichment {
return null;
}

if (!localStorage) {
return null;
}

return localStorage?.getItem(storageName);
}

Expand All @@ -243,6 +247,10 @@ export class Enrichment {
return;
}

if (!localStorage) {
return;
}

localStorage?.removeItem(storageName);
}

Expand Down
46 changes: 39 additions & 7 deletions src/Cache/SettingsCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,40 @@ 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' => [
[
'component' => 'submit',
'submitValue' => \__('Clear', 'eightshift-forms'),
'submitVariant' => 'ghost',
'submitAttrs' => [
UtilsHelper::getStateAttribute('cacheType') => 'all',
UtilsHelper::getStateAttribute('cacheType') => 'allInteral',
UtilsHelper::getStateAttribute('reload') => 'false',
],
'additionalClass' => UtilsHelper::getStateSelectorAdmin('cacheDelete'),
Expand All @@ -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,
],
];
}
}
3 changes: 3 additions & 0 deletions src/Hooks/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions src/Hooks/FiltersSettingsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/SettingsCloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
101 changes: 101 additions & 0 deletions src/Misc/SettingsRocketCache.php
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'),
],
],
],
];
}
}
2 changes: 1 addition & 1 deletion src/Misc/SettingsWpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Loading

0 comments on commit e6ebd77

Please sign in to comment.