Skip to content

Commit

Permalink
updating fixes for results (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic authored Jul 24, 2024
1 parent 442dbc4 commit 72da604
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 9 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [5.0.2]

### Added

- new integration filter `afterCustomResultOutputProcess`.

### Changed

- Removing copy for result output setting.

### Fixed

- JSON decode issue with the result output setting.

## [5.0.1]

### Changed
Expand Down Expand Up @@ -583,6 +597,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[5.0.1]: https://github.com/infinum/eightshift-forms/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/infinum/eightshift-forms/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/infinum/eightshift-forms/compare/4.0.7...5.0.0
[4.0.7]: https://github.com/infinum/eightshift-forms/compare/4.0.6...4.0.7
Expand Down
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 5.0.1
* Version: 5.0.2
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/FormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static function getComparator(string $action, string $start, string $valu
public static function checkResultOutputSuccess(string $name, string $operator, string $start, string $value, string $end): array
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$data = isset($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]) ? \json_decode(\esFormsDecryptor(\sanitize_text_field(\wp_unslash($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]))), true) : [];
$data = isset($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]) ? \json_decode(\esFormsDecryptor(\sanitize_text_field(\wp_unslash($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]))) ?: '', true) : [];

if (!$data) {
return [
Expand Down
13 changes: 13 additions & 0 deletions src/Hooks/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,23 @@ private static function getPublicFilters(): array
SettingsMailer::SETTINGS_TYPE_KEY => [
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsMailchimp::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsGreenhouse::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsHubspot::SETTINGS_TYPE_KEY => [
'filesOptions',
Expand All @@ -192,20 +195,23 @@ private static function getPublicFilters(): array
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsMailerlite::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsGoodbits::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsClearbit::SETTINGS_TYPE_KEY => [
'map',
Expand All @@ -216,20 +222,23 @@ private static function getPublicFilters(): array
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsAirtable::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsMoments::SETTINGS_TYPE_KEY => [
'data',
'order',
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
'prePostEventParams',
'prePostEventParamsAfter',
],
Expand All @@ -239,18 +248,22 @@ private static function getPublicFilters(): array
'prePostId',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsJira::SETTINGS_TYPE_KEY => [
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsPipedrive::SETTINGS_TYPE_KEY => [
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsCalculator::SETTINGS_TYPE_KEY => [
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
],
'entries' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Hooks/FiltersOuputMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static function getVariationFilterValue(string $type, string $formId, arr
// Get data from forms block.
$secureData = $formDetails[UtilsConfig::FD_SECURE_DATA] ?? [];
if ($secureData) {
$secureData = \json_decode(UtilsEncryption::decryptor($formDetails[UtilsConfig::FD_SECURE_DATA]), true)['v'] ?? [];
$secureData = \json_decode(UtilsEncryption::decryptor($formDetails[UtilsConfig::FD_SECURE_DATA]) ?: '', true)['v'] ?? [];

if ($secureData) {
$secureData = \array_column($secureData, 1, 0);
Expand Down
17 changes: 13 additions & 4 deletions src/Rest/Routes/AbstractFormSubmit.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ protected function getIntegrationResponseSuccessOutputAdditionalData(array $form

// Redirect secrue data.
if ($formDetails[UtilsConfig::FD_SECURE_DATA]) {
$secureData = \json_decode(UtilsEncryption::decryptor($formDetails[UtilsConfig::FD_SECURE_DATA]), true);
$secureData = \json_decode(UtilsEncryption::decryptor($formDetails[UtilsConfig::FD_SECURE_DATA]) ?: '', true);

// Legacy data.
if (isset($secureData['l'])) {
Expand All @@ -517,7 +517,7 @@ protected function getIntegrationResponseSuccessOutputAdditionalData(array $form
// Redirect custom result output feature.
$formsUseCustomResultOutputFeatureFilterName = UtilsHooksHelper::getFilterName(['block', 'forms', 'useCustomResultOutputFeature']);
if (\apply_filters($formsUseCustomResultOutputFeatureFilterName, false)) {
$redirectDataOutput[UtilsHelper::getStateSuccessRedirectUrlKey('customResultOutput')] = $this->processCustomResultOutputData($secureData, $formDetails[UtilsConfig::FD_PARAMS_RAW]);
$redirectDataOutput[UtilsHelper::getStateSuccessRedirectUrlKey('customResultOutput')] = $this->processCustomResultOutputData($secureData, $formDetails);
}
} else {
// Legacy data.
Expand Down Expand Up @@ -805,12 +805,16 @@ private function processLegacyData(array $data, array $params, string $formId):
* Process custom result output data.
*
* @param array<string, mixed> $data Data from secure data.
* @param array<string, mixed> $params Raw params.
* @param array<string, mixed> $formDetails Data passed from the `getFormDetailsApi` function.
*
* @return array<string, mixed>
*/
private function processCustomResultOutputData(array $data, array $params): array
private function processCustomResultOutputData(array $data, array $formDetails): array
{
$params = $formDetails[UtilsConfig::FD_PARAMS_RAW] ?? [];
$formId = $formDetails[UtilsConfig::FD_FORM_ID] ?? '';
$type = $formDetails[UtilsConfig::FD_TYPE] ?? '';

$output = [];

// Output title.
Expand Down Expand Up @@ -849,6 +853,11 @@ private function processCustomResultOutputData(array $data, array $params): arra
$output['d'] = $outputFiles;
}

$filterName = UtilsHooksHelper::getFilterName(['integrations', $type, 'afterCustomResultOutputProcess']);
if (\has_filter($filterName)) {
return \apply_filters($filterName, $output, $formDetails, $formId);
}

return $output;
}
}
2 changes: 1 addition & 1 deletion src/ResultOutput/SettingsResultOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getSettingsGlobalData(): array
'component' => 'input',
'inputName' => UtilsSettingsHelper::getOptionName(self::SETTINGS_GLOBAL_URL_PREFIX_KEY),
'inputFieldLabel' => \__('Global URL prefix', 'eightshift-forms'),
'inputFieldHelp' => \__('Define a global prefix for all the result output URLs. If you set this value with "/" your result outputs will not have a prefix but be careful as the created outputs can collide with other pages.', 'eightshift-forms'),
'inputFieldHelp' => \__('Define a global prefix for all the result output URLs.', 'eightshift-forms'),
'inputType' => 'text',
'inputPlaceholder' => Result::POST_TYPE_URL_SLUG,
'inputValue' => UtilsSettingsHelper::getOptionValue(self::SETTINGS_GLOBAL_URL_PREFIX_KEY),
Expand Down
2 changes: 1 addition & 1 deletion src/Shortcode/ResultOutputItemPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function callback(array $atts, string $content): string
private function getResultOutputSuccessItemPartShortcodeValue(string $name): array
{
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$data = isset($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]) ? \json_decode(\esFormsDecryptor(\sanitize_text_field(\wp_unslash($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]))), true) : [];
$data = isset($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]) ? \json_decode(\esFormsDecryptor(\sanitize_text_field(\wp_unslash($_GET[UtilsHelper::getStateSuccessRedirectUrlKey('data')]))) ?: '', true) : [];

if (!$data) {
return [
Expand Down

0 comments on commit 72da604

Please sign in to comment.