Skip to content

Commit

Permalink
updating forms to libs 8.0.0 and adding code corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Apr 29, 2024
1 parent 8a62081 commit 172aabe
Show file tree
Hide file tree
Showing 70 changed files with 507 additions and 417 deletions.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"issues": "https://github.com/infinum/eightshift-forms/issues",
"source": "https://github.com/infinum/eightshift-forms"
},

"require-dev": {
"brain/faker": "dev-master",
"brain/monkey": "^2.6.1",
Expand All @@ -37,10 +38,16 @@
"szepeviktor/phpstan-wordpress": "^1.3",
"wp-cli/wp-cli": "^2.9"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/infinum/eightshift-forms-utils.git"
}
],
"require": {
"php": "^7.4 || >=8.0",
"erusev/parsedown": "^1.7.4",
"infinum/eightshift-forms-utils": "^1.3.5"
"infinum/eightshift-forms-utils": "dev-feature/test-libs"
},
"autoload": {
"psr-4": {
Expand Down
285 changes: 162 additions & 123 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use EightshiftForms\Main\Main;
use EightshiftForms\Testfilters\Testfilters;
use EightshiftForms\Cache\ManifestCache;

/**
* If this file is called directly, abort.
Expand Down Expand Up @@ -62,6 +63,8 @@ function () {
if (\class_exists(Main::class)) {
$sep = \DIRECTORY_SEPARATOR;

(new ManifestCache())->setProjectAllCache();

(new Main($loader->getPrefixesPsr4(), __NAMESPACE__))->register();

// Require public helper class.
Expand Down
Empty file added setCache
Empty file.
3 changes: 2 additions & 1 deletion src/AdminMenus/FormAdminTopBarMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Helpers;
use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface;
use WP_Admin_Bar;

Expand Down Expand Up @@ -82,7 +83,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void
$isDevelopMode = UtilsDeveloperHelper::isDeveloperModeActive();
$isDevelopModeQmLog = UtilsDeveloperHelper::isDeveloperQMLogActive();

$version = UtilsGeneralHelper::getProjectVersion();
$version = Helpers::getPluginVersion();

$mainLabel = \esc_html__('Eightshift Forms', 'eightshift-forms');

Expand Down
20 changes: 16 additions & 4 deletions src/Blocks/SettingsBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

namespace EightshiftForms\Blocks;

use EightshiftForms\Cache\ManifestCache;
use EightshiftForms\Cache\SettingsCache;
use EightshiftForms\Geolocation\GeolocationInterface;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingInterface;
use EightshiftFormsVendor\EightshiftLibs\Cache\ManifestCacheInterface;
use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface;

/**
Expand Down Expand Up @@ -77,14 +78,25 @@ class SettingsBlocks implements UtilsSettingGlobalInterface, UtilsSettingInterfa
*/
protected GeolocationInterface $geolocation;

/**
* Instance variable for manifest cache.
*
* @var ManifestCacheInterface
*/
protected $manifestCache;

/**
* Create a new admin instance.
*
* @param GeolocationInterface $geolocation Inject geolocation which holds data about for storing to geolocation.
* @param ManifestCacheInterface $manifestCache Inject manifest cache.
*/
public function __construct(GeolocationInterface $geolocation)
{
public function __construct(
GeolocationInterface $geolocation,
ManifestCacheInterface $manifestCache
) {
$this->geolocation = $geolocation;
$this->manifestCache = $manifestCache;
}

/**
Expand Down Expand Up @@ -354,7 +366,7 @@ private function getCountriesDataSet(bool $useFullOutput = true): array
}

if (!$output) {
$countries = UtilsGeneralHelper::getCountrySelectList();
$countries = $this->manifestCache->getManifestCacheTopItem(ManifestCache::COUNTRIES_KEY, ManifestCache::TYPE_FORMS);

$output = [
'default' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/admin-listing/admin-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);
$manifestSection = Components::getComponent('admin-settings-section');

echo Components::outputCssVariablesGlobal(); // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
Expand Down
30 changes: 21 additions & 9 deletions src/Blocks/components/admin-settings/admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);
$manifestSection = Components::getComponent('admin-settings-section');

echo Components::outputCssVariablesGlobal(); // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
Expand Down Expand Up @@ -45,9 +45,14 @@
<?php if ($adminSettingsNotice) { ?>
<div class="<?php echo esc_attr("{$sectionClass}__notice"); ?>">
<?php
echo Components::render('notice', [
'noticeContent' => $adminSettingsNotice,
], '', true);
echo Components::render(
'notice',
[
'noticeContent' => $adminSettingsNotice,
],
'components',
true
);
?>
</div>
<?php } ?>
Expand All @@ -65,11 +70,18 @@

<?php
// phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
echo Components::renderPartial('component', $componentName, 'sidebar-section', [
'items' => $adminSettingsSidebar,
'sectionClass' => $sectionClass,
'adminSettingsType' => $adminSettingsType,
]);
echo $componentName;
echo Components::render(
'sidebar-section',
[
'items' => $adminSettingsSidebar,
'sectionClass' => $sectionClass,
'adminSettingsType' => $adminSettingsType,
],
'components',
false,
"{$componentName}/partials"
);
?>
</div>
<div class="<?php echo esc_attr("{$sectionClass}__main"); ?>">
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/card-inline/card-inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/checkbox/checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentName = $manifest['componentName'] ?? '';
$componentClass = $manifest['componentClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/checkboxes/checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$checkboxesName = Components::checkAttr('checkboxesName', $attributes, $manifest);
if (!$checkboxesName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$conditionalTagsUse = Components::checkAttr('conditionalTagsUse', $attributes, $manifest);
$conditionalTagsRules = Components::checkAttr('conditionalTagsRules', $attributes, $manifest);
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/container/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$containerUse = Components::checkAttr('containerUse', $attributes, $manifest);

Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/country/country.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);
$manifestSelect = Components::getComponent('select');

$componentName = $manifest['componentName'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/date/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/divider/divider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/dynamic/dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$dynamicName = Components::checkAttr('dynamicName', $attributes, $manifest);
if (!$dynamicName) {
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/error/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalErrorClass = $attributes['additionalErrorClass'] ?? '';
Expand Down
18 changes: 12 additions & 6 deletions src/Blocks/components/field/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$fieldUse = Components::checkAttr('fieldUse', $attributes, $manifest);
if (!$fieldUse) {
Expand Down Expand Up @@ -160,14 +160,20 @@ class="<?php echo esc_attr($fieldClass); ?>"

<?php
if ($fieldUniqueId) {
echo Components::outputCssVariables($attributes, $manifest, $fieldUniqueId, [], 'wp-block');
echo Components::outputCssVariables($attributes, $manifest, $fieldUniqueId, 'wp-block');
} else {
echo Components::outputCssVariables($attributes, $manifest, $unique);
}

echo Components::renderPartial('component', 'utils', 'debug-field-details', [ // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
'name' => Components::checkAttr('fieldName', $attributes, $manifest),
]);
echo Components::render(
'debug-field-details',
[
'name' => Components::checkAttr('fieldName', $attributes, $manifest),
],
'components',
false,
'utils/partials'
);

?>
<div class="<?php echo esc_attr("{$componentClass}__inner"); ?>">
Expand Down Expand Up @@ -219,7 +225,7 @@ class="<?php echo esc_attr($labelClass); ?>"
Components::props('error', $attributes, [
'errorId' => $fieldId,
'selectorClass' => $componentClass
])
]),
);
}
?>
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/file/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/form/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/global-msg/global-msg.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/group/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalGroupClass = $attributes['additionalGroupClass'] ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/input/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/intro/intro.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/invalid/invalid.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$heading = $attributes['heading'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/layout/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$layoutUse = Components::checkAttr('layoutUse', $attributes, $manifest);
if (!$layoutUse) {
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/loader/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper;
use EightshiftFormsVendor\EightshiftLibs\Helpers\Components;

$manifest = Components::getManifest(__DIR__);
$manifest = Components::getManifestByDir(__DIR__);

$componentClass = $manifest['componentClass'] ?? '';
$additionalClass = $attributes['additionalClass'] ?? '';
Expand Down
Loading

0 comments on commit 172aabe

Please sign in to comment.