Skip to content

Commit

Permalink
release 5.0.5 (#440)
Browse files Browse the repository at this point in the history
* adding new filter

* adding new api for custom api
  • Loading branch information
iruzevic authored Aug 12, 2024
1 parent fbc768a commit 043dc26
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 5 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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.5]

### Added

- new integration filter `overridePostRequest` to override the post request data.
- new public helper `getFormsGetCountryList` to get the list of countries.

## [5.0.4]

### Fixed
Expand Down Expand Up @@ -610,9 +617,10 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[5.0.3]: https://github.com/infinum/eightshift-forms/compare/5.0.3...5.0.4
[5.0.2]: https://github.com/infinum/eightshift-forms/compare/5.0.2...5.0.3
[5.0.1]: https://github.com/infinum/eightshift-forms/compare/5.0.1...5.0.2
[5.0.5]: https://github.com/infinum/eightshift-forms/compare/5.0.4...5.0.5
[5.0.4]: https://github.com/infinum/eightshift-forms/compare/5.0.3...5.0.4
[5.0.3]: https://github.com/infinum/eightshift-forms/compare/5.0.2...5.0.3
[5.0.2]: 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.4
* Version: 5.0.5
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
11 changes: 11 additions & 0 deletions src/Helpers/publicHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

use EightshiftForms\Cache\ManifestCache;
use EightshiftForms\Countries\Countries;
use EightshiftForms\Entries\EntriesHelper;
use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper;
use EightshiftForms\General\SettingsGeneral;
Expand Down Expand Up @@ -126,3 +127,13 @@ function esFormGetEntry(string $id): array
{
return EntriesHelper::getEntry($id);
}

/**
* Get countries data set depending on the provided filter and default set.
*
* @return array<string, mixed>
*/
function getFormsGetCountryList(): array
{
return (new Countries())->getCountriesDataSet();
}
12 changes: 12 additions & 0 deletions src/Hooks/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -184,6 +185,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -193,6 +195,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -201,6 +204,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -209,6 +213,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -220,6 +225,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -228,6 +234,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -236,6 +243,7 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand All @@ -246,21 +254,25 @@ private static function getPublicFilters(): array
'data',
'order',
'prePostId',
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsJira::SETTINGS_TYPE_KEY => [
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsPipedrive::SETTINGS_TYPE_KEY => [
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
],
SettingsCalculator::SETTINGS_TYPE_KEY => [
'overridePostRequest',
'prePostParams',
'beforeSuccessResponse',
'afterCustomResultOutputProcess',
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Airtable/AirtableClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ static function ($item) {
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsAirtable::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$body = [
'fields' => $this->prepareParams($params, $formId),
];
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Goodbits/GoodbitsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ public function getItem(string $itemId): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsGoodbits::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$body = [
'subscriber' => $this->prepareParams($params, $formId),
];
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Greenhouse/GreenhouseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ public function getItem(string $itemId): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsGreenhouse::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$paramsPrepared = $this->prepareParams($params, $formId);
$paramsFiles = $this->prepareFiles($files);

Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Hubspot/HubspotClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ public function getContactProperties(): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsHubspot::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$paramsPrepared = $this->prepareParams($params, $formId);
$paramsFiles = $this->prepareFiles($files, $formId);

Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Jira/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ public function getIssueType(string $itemId): array
*/
public function postApplication(array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsJira::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$url = $this->getBaseUrl() . "issue";

$body = [
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Mailchimp/MailchimpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ static function ($item) {
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsMailchimp::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$email = UtilsGeneralHelper::getEmailParamsField($params);
$emailHash = \md5(\strtolower($email));

Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Mailerlite/MailerliteClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ public function getItem(string $itemId): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsMailerlite::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$email = $params['email']['value'];

$body = [
Expand Down
12 changes: 11 additions & 1 deletion src/Integrations/Moments/MomentsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,21 @@ public function getItem(string $itemId): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsMoments::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$body = $this->prepareParams($params, $formId);

$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsMoments::SETTINGS_TYPE_KEY, 'prePostId']);
if (\has_filter($filterName)) {
$itemId = \apply_filters($filterName, $itemId, $body, $formId) ?? $itemId;
$itemId = \apply_filters($filterName, $itemId, $body, $formId);
}

$url = "{$this->getBaseUrl()}forms/1/forms/{$itemId}/data";
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Pipedrive/PipedriveClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ public function getLeadsFields(bool $hideUpdateTime = true): array
*/
public function postApplication(array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsPipedrive::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$organization = [];
$lead = [];
$person = [];
Expand Down
10 changes: 10 additions & 0 deletions src/Integrations/Workable/WorkableClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ public function getItem(string $itemId): array
*/
public function postApplication(string $itemId, array $params, array $files, string $formId): array
{
// Filter override post request.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsWorkable::SETTINGS_TYPE_KEY, 'overridePostRequest']);
if (\has_filter($filterName)) {
$filterValue = \apply_filters($filterName, [], $itemId, $params, $files, $formId) ?? [];

if ($filterValue) {
return $filterValue;
}
}

$paramsPrepared = $this->prepareParams($params, $formId);
$paramsFiles = $this->prepareFiles($files);

Expand Down
4 changes: 4 additions & 0 deletions src/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,16 @@ public function validateParams(array $formDetails, bool $strictValidation = true
break;
// Check validation for min array items length.
case 'minCount':
$inputValue = $inputValue ? \explode(UtilsConfig::DELIMITER, $inputValue) : [];

if ($dataValue > \count($inputValue)) {
$output[$paramKey] = \sprintf($this->getValidationLabel('validationMinCount', $formId), $dataValue);
}
break;
// Check validation for max array items length.
case 'maxCount':
$inputValue = $inputValue ? \explode(UtilsConfig::DELIMITER, $inputValue) : [];

if ($dataValue < \count($inputValue)) {
$output[$paramKey] = \sprintf($this->getValidationLabel('validationMaxCount', $formId), $dataValue);
}
Expand Down

0 comments on commit 043dc26

Please sign in to comment.