From 73487eb3219408acd069b3ab096649ade1433ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 31 Oct 2024 12:46:53 +0100 Subject: [PATCH] update release --- CHANGELOG.md | 7 +++++++ eightshift-forms.php | 2 +- src/Integrations/Talentlyft/Talentlyft.php | 19 ++++++++++++++----- .../Talentlyft/TalentlyftClient.php | 9 +++++---- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8904fa45..496d5a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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.1.7] + +### Fixed + +- TalentLyft integration custom fields not being saved correctly. + ## [5.1.6] ### Fixed @@ -716,6 +722,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Initial production release. +[5.1.6]: https://github.com/infinum/eightshift-forms/compare/5.1.6...5.1.7 [5.1.6]: https://github.com/infinum/eightshift-forms/compare/5.1.5...5.1.6 [5.1.5]: https://github.com/infinum/eightshift-forms/compare/5.1.4...5.1.5 [5.1.4]: https://github.com/infinum/eightshift-forms/compare/5.1.3...5.1.4 diff --git a/eightshift-forms.php b/eightshift-forms.php index f30c9045..3b3d47a7 100644 --- a/eightshift-forms.php +++ b/eightshift-forms.php @@ -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.1.6 + * Version: 5.1.7 * Text Domain: eightshift-forms * * @package EightshiftForms diff --git a/src/Integrations/Talentlyft/Talentlyft.php b/src/Integrations/Talentlyft/Talentlyft.php index 3d4252ad..b5519839 100644 --- a/src/Integrations/Talentlyft/Talentlyft.php +++ b/src/Integrations/Talentlyft/Talentlyft.php @@ -109,25 +109,34 @@ private function getFields(array $data, string $formId): array $output = []; - dump($data['fields']); - foreach ($data['fields'] as $item) { if (!$item) { continue; } + $customType = $item['FieldLocationType'] ?? ''; + $key = $item['Key'] ?? ''; + $type = $item['Type'] ?? ''; - $name = isset($item['Key']) ? "q_{$item['Key']}" : ''; - $tracking = $item['Key'] ?? ''; + $name = !empty($key) ? "q_{$key}" : ''; + $tracking = $key; $label = $item['DisplayName'] ?? ''; $fields = $item['Choices'] ?? []; - $internalType = ($item['FieldLocationType'] ?? '') === 'ScreeningQuestions' ? 'answers' : $type; + $internalType = $type; $required = isset($item['Required']) ? (bool) $item['Required'] : false; if (!$name) { $name = isset($item['Id']) ? "q_{$item['Id']}" : ''; } + if ($customType === 'ScreeningQuestions') { + $internalType = 'Answers'; + } + + if (empty($key)) { + $internalType = 'CustomFieldAnswers'; + } + if (!$name) { continue; } diff --git a/src/Integrations/Talentlyft/TalentlyftClient.php b/src/Integrations/Talentlyft/TalentlyftClient.php index c1c12319..4e5aaf95 100644 --- a/src/Integrations/Talentlyft/TalentlyftClient.php +++ b/src/Integrations/Talentlyft/TalentlyftClient.php @@ -285,7 +285,7 @@ public function getTestApi(): array */ private function getTalentlyftItems() { - $url = "{$this->getBaseUrl()}jobs?perPage=100"; + $url = "{$this->getBaseUrl()}jobs?perPage=100&status=internal"; $response = \wp_remote_get( $url, @@ -407,14 +407,15 @@ private function prepareParams(array $params, string $formId): array $name = \preg_replace('/^q_/', '', $name); switch ($typeCustom) { - case 'answers': + case 'Answers': + case 'CustomFieldAnswers': if (\in_array($type, ['radio', 'select', 'checkbox'], true)) { - $output['Answers'][] = [ + $output[$typeCustom][] = [ 'Id' => (int) $name, 'Choices' => \explode(UtilsConfig::DELIMITER, $value), ]; } else { - $output['Answers'][] = [ + $output[$typeCustom][] = [ 'Id' => (int) $name, 'Body' => $value, ];