From b6589449cbf4a348f4578cd0b04402ee7e1ae5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Thu, 5 Dec 2024 10:55:18 +0100 Subject: [PATCH] Release 5.5.0 (#467) * Adding corrections for the new HubSpot API v3 * updating locaitons and integration issues * Adding date and range field fixes * Writing changelog * updating utils * fixing corvus pay option * Update src/Blocks/components/form/assets-admin/transfer.js Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> * Update src/Rest/Routes/Settings/TransferRoute.php Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> * adding corvus IBAN pay * Adding additional statuses for integration * Update src/Integrations/Corvus/SettingsCorvus.php Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> * Updating changelog --------- Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- CHANGELOG.md | 25 + composer.json | 2 +- composer.lock | 14 +- eightshift-forms.php | 2 +- src/AdminMenus/FormAdminMenu.php | 24 +- .../date/components/date-options.js | 43 +- src/Blocks/components/date/date.php | 9 +- src/Blocks/components/date/manifest.json | 16 +- .../components/form/assets-admin/locations.js | 2 + .../components/form/assets-admin/transfer.js | 11 +- src/Blocks/components/form/assets/utils.js | 4 +- .../input/components/input-options.js | 17 +- src/Blocks/components/input/manifest.json | 15 +- src/Blocks/custom/forms/manifest.json | 6 +- .../components/result-output-editor.js | 115 ++-- src/Blocks/custom/result-output/manifest.json | 6 +- src/CustomPostType/Result.php | 16 +- src/Dashboard/SettingsDashboard.php | 2 +- src/Entries/SettingsEntries.php | 49 +- src/Helpers/publicHelper.php | 5 +- src/Hooks/FiltersSettingsBuilder.php | 10 - src/Integrations/Corvus/SettingsCorvus.php | 515 +++++++++--------- src/Integrations/Hubspot/HubspotClient.php | 40 +- src/Integrations/Hubspot/SettingsHubspot.php | 2 +- .../Talentlyft/SettingsTalentlyft.php | 26 + .../Talentlyft/TalentlyftClient.php | 48 +- .../Corvus/FormSubmitCorvusRoute.php | 12 +- src/Rest/Routes/Settings/BulkRoute.php | 3 +- src/Rest/Routes/Settings/LocationsRoute.php | 17 +- src/Rest/Routes/Settings/TransferRoute.php | 25 +- src/ResultOutput/SettingsResultOutput.php | 122 ----- src/Transfer/SettingsTransfer.php | 41 +- src/Transfer/Transfer.php | 29 +- src/Transfer/TransferInterface.php | 12 +- 34 files changed, 674 insertions(+), 611 deletions(-) delete mode 100644 src/ResultOutput/SettingsResultOutput.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c788f6..bc5f6fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,30 @@ 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.5.0] + +### Added + +- Locations ajax for results output listing. +- Option to customize Date and Time fields Preview and Output format. +- Result Outputs can now be exported and imported using settings. +- Settings entries list now has better UX in settings. +- `getFormUsageLocation` helper now supports custom post type. +- HubSpot integration now works using `v3` API for all data except form submission as it is not supported. +- Corvus Pay integration now supports IBAN payments. +- TalentLyft integration now supports additional statuses. + +### Fixed + +- Input Range status variable will output max 2 decimals. +- Input Range settings pickers broken up/down buttons. +- Corvus Pay integration fix with `Require complete` option. + +### Removed + +- Any Server Side Render for the forms and results output. +- Result Output global settings option to setup custom frontend URL. + ## [5.4.2] ### Updated @@ -796,6 +820,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Initial production release. +[5.5.0]: https://github.com/infinum/eightshift-forms/compare/5.4.2...5.5.0 [5.4.2]: https://github.com/infinum/eightshift-forms/compare/5.4.1...5.4.2 [5.4.1]: https://github.com/infinum/eightshift-forms/compare/5.4.0...5.4.1 [5.4.0]: https://github.com/infinum/eightshift-forms/compare/5.3.2...5.4.0 diff --git a/composer.json b/composer.json index 874d16fd..71bb864f 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require": { "php": ">=8.3", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "^3.0.7" + "infinum/eightshift-forms-utils": "^3.0.9" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 82bfbb89..4b539f04 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6f951ce6de7c3b76eb3adb2ad485f53b", + "content-hash": "e6be99a94da7f4622c6c755b2bc57a28", "packages": [ { "name": "erusev/parsedown", @@ -58,16 +58,16 @@ }, { "name": "infinum/eightshift-forms-utils", - "version": "3.0.7", + "version": "3.0.9", "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "94f0e6e9960106bbf2734e37e21ddad6748f0a2e" + "reference": "14c84dae774c522993da5b2026ed61cdea71076b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/94f0e6e9960106bbf2734e37e21ddad6748f0a2e", - "reference": "94f0e6e9960106bbf2734e37e21ddad6748f0a2e", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/14c84dae774c522993da5b2026ed61cdea71076b", + "reference": "14c84dae774c522993da5b2026ed61cdea71076b", "shasum": "" }, "require": { @@ -120,7 +120,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-11-26T13:13:55+00:00" + "time": "2024-12-03T12:02:05+00:00" }, { "name": "infinum/eightshift-libs", @@ -4958,6 +4958,6 @@ "platform": { "php": ">=8.3" }, - "platform-dev": [], + "platform-dev": {}, "plugin-api-version": "2.6.0" } diff --git a/eightshift-forms.php b/eightshift-forms.php index 2a1c46c6..298171a0 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.4.2 + * Version: 5.5.0 * Text Domain: eightshift-forms * * @package EightshiftForms diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index debd87dd..502c12aa 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -16,7 +16,6 @@ use EightshiftFormsVendor\EightshiftLibs\Helpers\Helpers; use EightshiftForms\Misc\SettingsWpml; use EightshiftForms\Listing\FormListingInterface; -use EightshiftForms\ResultOutput\SettingsResultOutput; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; @@ -196,7 +195,7 @@ protected function processAttributes($attr): array switch ($type) { case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: - $items = UtilsGeneralHelper::getBlockLocations($formId); + $items = UtilsGeneralHelper::getBlockLocations($formId, ''); $count = \count($items); $formTitle = \get_the_title((int) $formId); @@ -967,6 +966,15 @@ private function getRightContent(array $item, string $type, string $parent): arr break; case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: $output = [ + Helpers::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Locations', 'eightshift-forms'), + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('locationsId') => $formId, + UtilsHelper::getStateAttribute('locationsType') => Result::POST_TYPE_SLUG, + ], + 'additionalClass' => UtilsHelper::getStateSelectorAdmin('listingLocations'), + ]), Helpers::render('submit', [ 'submitVariant' => 'ghost', 'submitButtonAsLink' => true, @@ -974,15 +982,6 @@ private function getRightContent(array $item, string $type, string $parent): arr 'submitValue' => \__('Edit', 'eightshift-forms'), ]), ]; - - if (\apply_filters(SettingsResultOutput::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false)) { - $output[] = Helpers::render('submit', [ - 'submitVariant' => 'ghost', - 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => \get_permalink($formId), - 'submitValue' => \__('View', 'eightshift-forms'), - ]); - } break; case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $output = []; @@ -996,7 +995,8 @@ private function getRightContent(array $item, string $type, string $parent): arr 'submitVariant' => 'ghost', 'submitValue' => \__('Locations', 'eightshift-forms'), 'submitAttrs' => [ - UtilsHelper::getStateAttribute('locationsId') => $formId + UtilsHelper::getStateAttribute('locationsId') => $formId, + UtilsHelper::getStateAttribute('locationsType') => Forms::POST_TYPE_SLUG, ], 'additionalClass' => UtilsHelper::getStateSelectorAdmin('listingLocations'), ]), diff --git a/src/Blocks/components/date/components/date-options.js b/src/Blocks/components/date/components/date-options.js index 5144f7fd..36a743f4 100644 --- a/src/Blocks/components/date/components/date-options.js +++ b/src/Blocks/components/date/components/date-options.js @@ -4,8 +4,8 @@ import React from 'react'; import { isArray } from 'lodash'; import { select } from '@wordpress/data'; import { useState } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; -import { TextControl, PanelBody } from '@wordpress/components'; +import { __, sprintf } from '@wordpress/i18n'; +import { TextControl, PanelBody, Button } from '@wordpress/components'; import { icons, checkAttr, @@ -43,6 +43,8 @@ export const DateOptions = (attributes) => { const dateDisabledOptions = checkAttr('dateDisabledOptions', attributes, manifest); const dateType = checkAttr('dateType', attributes, manifest); const dateUseLabelAsPlaceholder = checkAttr('dateUseLabelAsPlaceholder', attributes, manifest); + const datePreviewFormat = checkAttr('datePreviewFormat', attributes, manifest); + const dateOutputFormat = checkAttr('dateOutputFormat', attributes, manifest); let dateValidationPatternOptions = []; @@ -134,6 +136,43 @@ export const DateOptions = (attributes) => { /> +
+ {__('You can use any valid formats by visiting the following button.', 'eightshift-forms')} + +

+ + + +

+ + } + value={datePreviewFormat} + placeholder={manifest.formats[dateType].preview} + help={__('Define format of date/time the user will see', 'eightshift-forms')} + onChange={(value) => setAttributes({ [getAttrKey('datePreviewFormat', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('datePreviewFormat', attributes, manifest), dateDisabledOptions)} + /> + + } + value={dateOutputFormat} + placeholder={manifest.formats[dateType].output} + help={__('Define format of date/time that will be sent when form is processed', 'eightshift-forms')} + onChange={(value) => setAttributes({ [getAttrKey('dateOutputFormat', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('dateOutputFormat', attributes, manifest), dateDisabledOptions)} + /> +
+
} diff --git a/src/Blocks/components/date/date.php b/src/Blocks/components/date/date.php index be597b84..dd540b17 100644 --- a/src/Blocks/components/date/date.php +++ b/src/Blocks/components/date/date.php @@ -55,13 +55,8 @@ $dateAttrs['placeholder'] = esc_attr($datePlaceholder); } -if ($datePreviewFormat) { - $dateAttrs[UtilsHelper::getStateAttribute('datePreviewFormat')] = esc_attr($datePreviewFormat); -} - -if ($dateOutputFormat) { - $dateAttrs[UtilsHelper::getStateAttribute('dateOutputFormat')] = esc_attr($dateOutputFormat); -} +$dateAttrs[UtilsHelper::getStateAttribute('datePreviewFormat')] = $datePreviewFormat ? esc_attr($datePreviewFormat) : $manifest['formats'][$dateType]['preview']; +$dateAttrs[UtilsHelper::getStateAttribute('dateOutputFormat')] = $dateOutputFormat ? esc_attr($dateOutputFormat) : $manifest['formats'][$dateType]['output']; if ($dateUseLabelAsPlaceholder) { $dateAttrs['placeholder'] = esc_attr($dateFieldLabel); diff --git a/src/Blocks/components/date/manifest.json b/src/Blocks/components/date/manifest.json index ce161137..21f47a7a 100644 --- a/src/Blocks/components/date/manifest.json +++ b/src/Blocks/components/date/manifest.json @@ -69,12 +69,10 @@ "type": "array" }, "datePreviewFormat": { - "type": "string", - "default": "F j, Y H:i" + "type": "string" }, "dateOutputFormat": { - "type": "string", - "default": "Y-m-d H:i" + "type": "string" }, "dateTwSelectorsData": { "type": "array" @@ -91,5 +89,15 @@ "value": "datetime-local" } ] + }, + "formats": { + "date": { + "preview": "F j, Y", + "output": "Y-m-d" + }, + "datetime-local": { + "preview": "F j, Y H:i", + "output": "Y-m-d H:i" + } } } diff --git a/src/Blocks/components/form/assets-admin/locations.js b/src/Blocks/components/form/assets-admin/locations.js index 81f6a9ba..dae57a25 100644 --- a/src/Blocks/components/form/assets-admin/locations.js +++ b/src/Blocks/components/form/assets-admin/locations.js @@ -26,6 +26,7 @@ export class Locations { const formData = new FormData(); formData.append('id', field.getAttribute(this.state.getStateAttribute('locationsId'))); + formData.append('type', field.getAttribute(this.state.getStateAttribute('locationsType'))); this.utils.showLoader(this.FORM_ID); // Populate body data. @@ -56,6 +57,7 @@ export class Locations { if (response.status === 'success') { item.classList.add(this.state.getStateSelector('isHidden')); item.closest(this.itemSelector).insertAdjacentHTML('afterend', response.data.output); + item.remove(); } }); }; diff --git a/src/Blocks/components/form/assets-admin/transfer.js b/src/Blocks/components/form/assets-admin/transfer.js index c8ce9509..7ae671f3 100644 --- a/src/Blocks/components/form/assets-admin/transfer.js +++ b/src/Blocks/components/form/assets-admin/transfer.js @@ -98,16 +98,17 @@ export class Transfer { }; onClickItem = (event) => { - const button = document.querySelector(`${this.state.getStateSelector('field', true)}[${this.state.getStateAttribute('migrationType')}='export-forms']`); - const items = button.getAttribute(this.state.getStateAttribute('migrationExportItems')); - - let output = items ? items.split(",") : []; - const { value, checked, + name, } = event.target; + const button = document.querySelector(`${this.state.getStateSelector('field', true)}[${this.state.getStateAttribute('migrationType')}='${name}']`); + const items = button?.getAttribute(this.state.getStateAttribute('migrationExportItems')); + + let output = items ? items.split(",") : []; + if (checked) { output.push(value); } else { diff --git a/src/Blocks/components/form/assets/utils.js b/src/Blocks/components/form/assets/utils.js index 7d8a3292..199e6077 100644 --- a/src/Blocks/components/form/assets/utils.js +++ b/src/Blocks/components/form/assets/utils.js @@ -1229,8 +1229,8 @@ export class Utils { if (input) { const min = input.min || 0; const max = input.max || 100; - const parsedProgress = Number(((input.value - min) * 100) / (max - min)); - + const parsedProgress = (Number(((input.value - min) * 100) / (max - min))).toFixed(2); + input.style.setProperty('--es-form-range-progress', `${parsedProgress}%`); } diff --git a/src/Blocks/components/input/components/input-options.js b/src/Blocks/components/input/components/input-options.js index 8653b256..81a0da0b 100644 --- a/src/Blocks/components/input/components/input-options.js +++ b/src/Blocks/components/input/components/input-options.js @@ -240,10 +240,11 @@ export const InputOptions = (attributes) => { value={inputMinLength} onChange={(value) => setAttributes({ [getAttrKey('inputMinLength', attributes, manifest)]: value })} min={options.inputMinLength.min} + max={options.inputMinLength.max} step={options.inputMinLength.step} disabled={isOptionDisabled(getAttrKey('inputMinLength', attributes, manifest), inputDisabledOptions)} placeholder='–' - fixedWidth={4} + fixedWidth={5} noBottomSpacing /> @@ -267,10 +268,11 @@ export const InputOptions = (attributes) => { value={inputMaxLength} onChange={(value) => setAttributes({ [getAttrKey('inputMaxLength', attributes, manifest)]: value })} min={options.inputMaxLength.min} + max={options.inputMaxLength.max} step={options.inputMaxLength.step} disabled={isOptionDisabled(getAttrKey('inputMaxLength', attributes, manifest), inputDisabledOptions)} placeholder='–' - fixedWidth={4} + fixedWidth={5} noBottomSpacing /> @@ -400,10 +402,11 @@ export const InputOptions = (attributes) => { value={inputMin} onChange={(value) => setAttributes({ [getAttrKey('inputMin', attributes, manifest)]: formatNumber(value) })} min={options.inputMin.min} + max={options.inputMin.max} step={options.inputMin.step} disabled={isOptionDisabled(getAttrKey('inputMin', attributes, manifest), inputDisabledOptions)} placeholder='–' - fixedWidth={4} + fixedWidth={5} noBottomSpacing /> @@ -426,10 +429,11 @@ export const InputOptions = (attributes) => { value={inputMax} onChange={(value) => setAttributes({ [getAttrKey('inputMax', attributes, manifest)]: formatNumber(value) })} min={options.inputMax.min} + max={options.inputMax.max} step={options.inputMax.step} disabled={isOptionDisabled(getAttrKey('inputMax', attributes, manifest), inputDisabledOptions)} placeholder='–' - fixedWidth={4} + fixedWidth={5} noBottomSpacing /> @@ -453,11 +457,12 @@ export const InputOptions = (attributes) => {
setAttributes({ [getAttrKey('inputStep', attributes, manifest)]: formatNumber(value) })} + onChange={(value) => setAttributes({ [getAttrKey('inputStep', attributes, manifest)]: value })} min={options.inputStep.min} + max={options.inputStep.max} step={options.inputStep.step} disabled={isOptionDisabled(getAttrKey('inputStep', attributes, manifest), inputDisabledOptions)} - fixedWidth={4} + fixedWidth={5} noBottomSpacing /> diff --git a/src/Blocks/components/input/manifest.json b/src/Blocks/components/input/manifest.json index aaefb088..ff3a8ff3 100644 --- a/src/Blocks/components/input/manifest.json +++ b/src/Blocks/components/input/manifest.json @@ -158,23 +158,28 @@ } ], "inputMinLength": { - "min": 0, + "min": 0, + "max": 999999, "step": 1 }, "inputMaxLength": { - "min": 1, + "min": 1, + "max": 999999, "step": 1 }, "inputMin": { - "min": 0.01, + "min": 0, + "max": 999999, "step": 0.01 }, "inputMax": { - "min": 0.01, + "min": 0, + "max": 999999, "step": 0.01 }, "inputStep": { - "min": 0.01, + "min": 0.01, + "max": 1, "step": 0.01 } } diff --git a/src/Blocks/custom/forms/manifest.json b/src/Blocks/custom/forms/manifest.json index fedf5596..7de5bdbf 100644 --- a/src/Blocks/custom/forms/manifest.json +++ b/src/Blocks/custom/forms/manifest.json @@ -88,9 +88,5 @@ "components": { "conditionalTags": "conditionalTags", "progressBar": "progressBar" - }, - "attributesSsr": [ - "formsFormPostId", - "formsStyle" - ] + } } diff --git a/src/Blocks/custom/result-output/components/result-output-editor.js b/src/Blocks/custom/result-output/components/result-output-editor.js index 5cfc8946..d97b3415 100644 --- a/src/Blocks/custom/result-output/components/result-output-editor.js +++ b/src/Blocks/custom/result-output/components/result-output-editor.js @@ -1,6 +1,6 @@ import React from 'react'; import { select } from '@wordpress/data'; -import { ServerSideRender, +import { checkAttr, icons, AsyncSelect, @@ -9,7 +9,7 @@ import { ServerSideRender, } from '@eightshift/frontend-libs/scripts'; import { __ } from '@wordpress/i18n'; import { Placeholder } from '@wordpress/components'; -import { getFilteredAttributes, outputFormSelectItemWithIcon } from '../../../components/utils'; +import { outputFormSelectItemWithIcon } from '../../../components/utils'; export const ResultOutputEditor = ({ attributes, @@ -19,79 +19,54 @@ export const ResultOutputEditor = ({ }) => { const manifest = select(STORE_NAME).getBlock('result-output'); - const { - blockFullName - } = attributes; - - const { - attributesSsr, - } = manifest; - const resultOutputFormPostId = checkAttr('resultOutputFormPostId', attributes, manifest); const resultOutputFormPostIdRaw = checkAttr('resultOutputFormPostIdRaw', attributes, manifest); const resultOutputPostIdRaw = checkAttr('resultOutputPostIdRaw', attributes, manifest); const resultOutputPostId = checkAttr('resultOutputPostId', attributes, manifest); - if (resultOutputPostId?.length < 1 || resultOutputFormPostId?.length < 1) { - return ( - {__('Eightshift Forms - Result output', 'eightshift-forms')}} - className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' - > - { - setAttributes({ - [getAttrKey('resultOutputPostIdRaw', attributes, manifest)]: { - id: value?.id, - label: value?.metadata?.label, - value: value?.metadata?.value, - metadata: value?.metadata?.metadata, - }, - [getAttrKey('resultOutputPostId', attributes, manifest)]: `${value?.value}`, - }); - }} - noBottomSpacing - /> - - { - setAttributes({ - [getAttrKey('resultOutputFormPostIdRaw', attributes, manifest)]: { - id: value?.id, - label: value?.metadata?.label, - value: value?.metadata?.value, - metadata: value?.metadata?.metadata, - }, - [getAttrKey('resultOutputFormPostId', attributes, manifest)]: `${value?.value}`, - }); - }} - noBottomSpacing - /> - - ); - } - return ( - + {__('Eightshift Forms - Result output', 'eightshift-forms')}} + className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' + > + { + setAttributes({ + [getAttrKey('resultOutputPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('resultOutputPostId', attributes, manifest)]: `${value?.value}`, + }); + }} + noBottomSpacing + /> + + { + setAttributes({ + [getAttrKey('resultOutputFormPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('resultOutputFormPostId', attributes, manifest)]: `${value?.value}`, + }); + }} + noBottomSpacing + /> + ); }; diff --git a/src/Blocks/custom/result-output/manifest.json b/src/Blocks/custom/result-output/manifest.json index b91da7f1..1149ea93 100644 --- a/src/Blocks/custom/result-output/manifest.json +++ b/src/Blocks/custom/result-output/manifest.json @@ -40,9 +40,5 @@ "type": "boolean", "default": false } - }, - "attributesSsr": [ - "resultOutputPostId", - "resultOutputFormPostId" - ] + } } diff --git a/src/CustomPostType/Result.php b/src/CustomPostType/Result.php index 54a21897..3a3fcb98 100644 --- a/src/CustomPostType/Result.php +++ b/src/CustomPostType/Result.php @@ -10,9 +10,7 @@ namespace EightshiftForms\CustomPostType; -use EightshiftForms\ResultOutput\SettingsResultOutput; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; -use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftFormsVendor\EightshiftLibs\CustomPostType\AbstractPostType; /** @@ -114,19 +112,11 @@ protected function getPostTypeArguments(): array 'can_export' => true, 'capability_type' => self::POST_CAPABILITY_TYPE, 'rest_base' => static::REST_API_ENDPOINT_SLUG, + 'rewrite' => [ + 'with_front' => false, + ], ]; - if (\apply_filters(SettingsResultOutput::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false)) { - $output['publicly_queryable'] = true; - $output['rewrite']['with_front'] = false; - - $prefix = UtilsSettingsHelper::getOptionValue(SettingsResultOutput::SETTINGS_GLOBAL_URL_PREFIX_KEY); - - if ($prefix) { - $output['rewrite']['slug'] = $prefix; - } - } - return $output; } } diff --git a/src/Dashboard/SettingsDashboard.php b/src/Dashboard/SettingsDashboard.php index b7abf7a1..ee81d685 100644 --- a/src/Dashboard/SettingsDashboard.php +++ b/src/Dashboard/SettingsDashboard.php @@ -96,7 +96,7 @@ public function getSettingsGlobalData(): array ], ], ], - ] + ], ]; $filtered[$value['type']][] = $item; diff --git a/src/Entries/SettingsEntries.php b/src/Entries/SettingsEntries.php index 61d2fd48..6d19b0c3 100644 --- a/src/Entries/SettingsEntries.php +++ b/src/Entries/SettingsEntries.php @@ -153,35 +153,46 @@ public function getSettingsData(string $formId): array return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), [ - 'component' => 'tabs', - 'tabsFull' => true, - 'tabsContent' => [ + 'component' => 'layout', + 'layoutType' => 'layout-v-stack-clean', + 'layoutContent' => [ [ - 'component' => 'tab', - 'tabLabel' => \__('Options', 'eightshift-forms'), - 'tabContent' => [ + 'component' => 'card-inline', + 'cardInlineTitle' => \__('Store entries in database', 'eightshift-forms'), + 'cardInlineRightContent' => [ + $isUsed ? [ + 'component' => 'submit', + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES, $formId), + 'submitValue' => \__('View', 'eightshift-forms'), + ] : [], [ 'component' => 'checkboxes', - 'checkboxesFieldLabel' => '', 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_ENTRIES_SETTINGS_USE_KEY), 'checkboxesContent' => [ [ 'component' => 'checkbox', - 'checkboxLabel' => \__('Store entries in database', 'eightshift-forms'), - // translators: %s is replaced with the form entries page URL. - 'checkboxHelp' => $isUsed ? \sprintf(\__("You can find all form entries here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES, $formId)) : '', 'checkboxIsChecked' => $isUsed, 'checkboxValue' => self::SETTINGS_ENTRIES_SETTINGS_USE_KEY, 'checkboxSingleSubmit' => true, 'checkboxAsToggle' => true, - ] - ] - ], - ...($isUsed ? [ - [ - 'component' => 'divider', - 'dividerExtraVSpacing' => true, + ], ], + ], + ], + ], + ], + ], + ...($isUsed ? [ + [ + 'component' => 'tabs', + 'tabsFull' => true, + 'tabsContent' => [ + [ + 'component' => 'tab', + 'tabLabel' => \__('Options', 'eightshift-forms'), + 'tabContent' => [ [ 'component' => 'checkboxes', 'checkboxesFieldLabel' => '', @@ -227,11 +238,11 @@ public function getSettingsData(string $formId): array ] ] ], - ] : []), + ], ], ], ], - ], + ] : []), ]; } diff --git a/src/Helpers/publicHelper.php b/src/Helpers/publicHelper.php index 377ecac3..29e64b0d 100644 --- a/src/Helpers/publicHelper.php +++ b/src/Helpers/publicHelper.php @@ -148,10 +148,11 @@ function getFormsGetCountryList(): array * Get form usage location. * * @param string $formId Form ID. + * @param string $type Type. * * @return array */ -function getFormUsageLocation(string $formId): array +function getFormUsageLocation(string $formId, string $type = ''): array { - return UtilsGeneralHelper::getBlockLocations($formId); + return UtilsGeneralHelper::getBlockLocations($formId, $type); } diff --git a/src/Hooks/FiltersSettingsBuilder.php b/src/Hooks/FiltersSettingsBuilder.php index 982f4a25..e09606f7 100644 --- a/src/Hooks/FiltersSettingsBuilder.php +++ b/src/Hooks/FiltersSettingsBuilder.php @@ -65,7 +65,6 @@ use EightshiftForms\Misc\SettingsCloudflare; use EightshiftForms\Misc\SettingsRocketCache; use EightshiftForms\Misc\SettingsWpml; -use EightshiftForms\ResultOutput\SettingsResultOutput; use EightshiftForms\Security\SettingsSecurity; use EightshiftForms\Validation\SettingsValidation; use EightshiftForms\Validation\Validator; @@ -210,15 +209,6 @@ public function getSettingsFiltersData(): array 'desc' => \__('Collect form entries in your project database.', 'eightshift-forms'), ], ], - SettingsResultOutput::SETTINGS_TYPE_KEY => [ - 'settingsGlobal' => SettingsResultOutput::FILTER_SETTINGS_GLOBAL_NAME, - 'type' => UtilsConfig::SETTINGS_INTERNAL_TYPE_ADVANCED, - 'use' => SettingsResultOutput::SETTINGS_USE_KEY, - 'labels' => [ - 'title' => \__('Result outputs', 'eightshift-forms'), - 'desc' => \__('Output form results to various services like "thank you" pages.', 'eightshift-forms'), - ], - ], // ------------------------------ // INTEGRATIONS. // ------------------------------ diff --git a/src/Integrations/Corvus/SettingsCorvus.php b/src/Integrations/Corvus/SettingsCorvus.php index 99f020da..9b4e145b 100644 --- a/src/Integrations/Corvus/SettingsCorvus.php +++ b/src/Integrations/Corvus/SettingsCorvus.php @@ -55,6 +55,11 @@ class SettingsCorvus extends AbstractSettingsIntegrations implements UtilsSettin */ public const SETTINGS_CORVUS_USE_KEY = 'corvus-use'; + /** + * Corvus IBAN use key. + */ + public const SETTINGS_CORVUS_IBAN_USE_KEY = 'corvus-iban-use'; + /** * API Key. */ @@ -216,6 +221,7 @@ public function getSettingsData(string $formId): array [ 'component' => 'select', 'selectIsRequired' => true, + 'selectSingleSubmit' => true, 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_STORE_ID), 'selectFieldLabel' => \__('Store ID', 'eightshift-forms'), 'selectPlaceholder' => \__('Select Store ID', 'eightshift-forms'), @@ -231,252 +237,275 @@ static function ($option) use ($selectedStoreId) { UtilsSettingsHelper::getOptionValueGroup(self::SETTINGS_CORVUS_STORE_IDS_KEY) ), ], - [ - 'component' => 'select', - 'selectIsRequired' => true, - 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_LANG_KEY), - 'selectFieldLabel' => \__('Language', 'eightshift-forms'), - 'selectPlaceholder' => \__('Select language', 'eightshift-forms'), - 'selectContent' => [ - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Croatian', 'eightshift-forms'), - 'selectOptionValue' => 'hr', - 'selectOptionIsSelected' => $lang === 'hr', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('English', 'eightshift-forms'), - 'selectOptionValue' => 'en', - 'selectOptionIsSelected' => $lang === 'en', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Italian', 'eightshift-forms'), - 'selectOptionValue' => 'it', - 'selectOptionIsSelected' => $lang === 'it', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('German', 'eightshift-forms'), - 'selectOptionValue' => 'de', - 'selectOptionIsSelected' => $lang === 'de', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Serbian', 'eightshift-forms'), - 'selectOptionValue' => 'rs', - 'selectOptionIsSelected' => $lang === 'rs', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Slovenian', 'eightshift-forms'), - 'selectOptionValue' => 'sl', - 'selectOptionIsSelected' => $lang === 'sl', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Macedonian', 'eightshift-forms'), - 'selectOptionValue' => 'mk', - 'selectOptionIsSelected' => $lang === 'mk', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Albanian', 'eightshift-forms'), - 'selectOptionValue' => 'sq', - 'selectOptionIsSelected' => $lang === 'sq', - ], - ] - ], - [ - 'component' => 'select', - 'selectIsRequired' => true, - 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_CURRENCY_KEY), - 'selectFieldLabel' => \__('Currency', 'eightshift-forms'), - 'selectPlaceholder' => \__('Select currency', 'eightshift-forms'), - 'selectContent' => [ - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Euro', 'eightshift-forms'), - 'selectOptionValue' => 'EUR', - 'selectOptionIsSelected' => $currency === 'EUR', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('British Pound', 'eightshift-forms'), - 'selectOptionValue' => 'GBP', - 'selectOptionIsSelected' => $currency === 'GBP', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('US Dollar', 'eightshift-forms'), - 'selectOptionValue' => 'USD', - 'selectOptionIsSelected' => $currency === 'USD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Danish Krone', 'eightshift-forms'), - 'selectOptionValue' => 'DKK', - 'selectOptionIsSelected' => $currency === 'DKK', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Norwegian Krone', 'eightshift-forms'), - 'selectOptionValue' => 'NOK', - 'selectOptionIsSelected' => $currency === 'NOK', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Swedish Krona', 'eightshift-forms'), - 'selectOptionValue' => 'SEK', - 'selectOptionIsSelected' => $currency === 'SEK', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Swiss Franc', 'eightshift-forms'), - 'selectOptionValue' => 'CHF', - 'selectOptionIsSelected' => $currency === 'CHF', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Canadian Dollar', 'eightshift-forms'), - 'selectOptionValue' => 'CAD', - 'selectOptionIsSelected' => $currency === 'CAD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Hungarian Forint', 'eightshift-forms'), - 'selectOptionValue' => 'HUF', - 'selectOptionIsSelected' => $currency === 'HUF', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Bahraini Dinar', 'eightshift-forms'), - 'selectOptionValue' => 'BHD', - 'selectOptionIsSelected' => $currency === 'BHD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Australian Dollar', 'eightshift-forms'), - 'selectOptionValue' => 'AUD', - 'selectOptionIsSelected' => $currency === 'AUD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Russian Ruble', 'eightshift-forms'), - 'selectOptionValue' => 'RUB', - 'selectOptionIsSelected' => $currency === 'RUB', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Polish Zloty', 'eightshift-forms'), - 'selectOptionValue' => 'PLN', - 'selectOptionIsSelected' => $currency === 'PLN', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Romanian Leu', 'eightshift-forms'), - 'selectOptionValue' => 'RON', - 'selectOptionIsSelected' => $currency === 'RON', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Czech Koruna', 'eightshift-forms'), - 'selectOptionValue' => 'CZK', - 'selectOptionIsSelected' => $currency === 'CZK', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Icelandic Krona', 'eightshift-forms'), - 'selectOptionValue' => 'ISK', - 'selectOptionIsSelected' => $currency === 'ISK', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Bosnia-Herzegovina Convertible Mark', 'eightshift-forms'), - 'selectOptionValue' => 'BAM', - 'selectOptionIsSelected' => $currency === 'BAM', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Serbian Dinar', 'eightshift-forms'), - 'selectOptionValue' => 'RSD', - 'selectOptionIsSelected' => $currency === 'RSD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Macedonian Denar', 'eightshift-forms'), - 'selectOptionValue' => 'MKD', - 'selectOptionIsSelected' => $currency === 'MKD', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Bulgarian Lev', 'eightshift-forms'), - 'selectOptionValue' => 'BGN', - 'selectOptionIsSelected' => $currency === 'BGN', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Albanian Lek', 'eightshift-forms'), - 'selectOptionValue' => 'ALL', - 'selectOptionIsSelected' => $currency === 'ALL', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Turkish Lira', 'eightshift-forms'), - 'selectOptionValue' => 'TRY', - 'selectOptionIsSelected' => $currency === 'TRY', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Israeli Shekel', 'eightshift-forms'), - 'selectOptionValue' => 'ILS', - 'selectOptionIsSelected' => $currency === 'ILS', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('United Arab Emirates Dirham', 'eightshift-forms'), - 'selectOptionValue' => 'AED', - 'selectOptionIsSelected' => $currency === 'AED', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Chinese Yuan', 'eightshift-forms'), - 'selectOptionValue' => 'CNY', - 'selectOptionIsSelected' => $currency === 'CNY', - ], - [ - 'component' => 'select-option', - 'selectOptionLabel' => \__('Japanese Yen', 'eightshift-forms'), - 'selectOptionValue' => 'JPY', - 'selectOptionIsSelected' => $currency === 'JPY', + ...($selectedStoreId ? [ + [ + 'component' => 'select', + 'selectIsRequired' => true, + 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_LANG_KEY), + 'selectFieldLabel' => \__('Language', 'eightshift-forms'), + 'selectPlaceholder' => \__('Select language', 'eightshift-forms'), + 'selectContent' => [ + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Croatian', 'eightshift-forms'), + 'selectOptionValue' => 'hr', + 'selectOptionIsSelected' => $lang === 'hr', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('English', 'eightshift-forms'), + 'selectOptionValue' => 'en', + 'selectOptionIsSelected' => $lang === 'en', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Italian', 'eightshift-forms'), + 'selectOptionValue' => 'it', + 'selectOptionIsSelected' => $lang === 'it', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('German', 'eightshift-forms'), + 'selectOptionValue' => 'de', + 'selectOptionIsSelected' => $lang === 'de', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Serbian', 'eightshift-forms'), + 'selectOptionValue' => 'rs', + 'selectOptionIsSelected' => $lang === 'rs', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Slovenian', 'eightshift-forms'), + 'selectOptionValue' => 'sl', + 'selectOptionIsSelected' => $lang === 'sl', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Macedonian', 'eightshift-forms'), + 'selectOptionValue' => 'mk', + 'selectOptionIsSelected' => $lang === 'mk', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Albanian', 'eightshift-forms'), + 'selectOptionValue' => 'sq', + 'selectOptionIsSelected' => $lang === 'sq', + ], + ] + ], + [ + 'component' => 'select', + 'selectIsRequired' => true, + 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_CURRENCY_KEY), + 'selectFieldLabel' => \__('Currency', 'eightshift-forms'), + 'selectPlaceholder' => \__('Select currency', 'eightshift-forms'), + 'selectContent' => [ + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Euro', 'eightshift-forms'), + 'selectOptionValue' => 'EUR', + 'selectOptionIsSelected' => $currency === 'EUR', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('British Pound', 'eightshift-forms'), + 'selectOptionValue' => 'GBP', + 'selectOptionIsSelected' => $currency === 'GBP', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('US Dollar', 'eightshift-forms'), + 'selectOptionValue' => 'USD', + 'selectOptionIsSelected' => $currency === 'USD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Danish Krone', 'eightshift-forms'), + 'selectOptionValue' => 'DKK', + 'selectOptionIsSelected' => $currency === 'DKK', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Norwegian Krone', 'eightshift-forms'), + 'selectOptionValue' => 'NOK', + 'selectOptionIsSelected' => $currency === 'NOK', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Swedish Krona', 'eightshift-forms'), + 'selectOptionValue' => 'SEK', + 'selectOptionIsSelected' => $currency === 'SEK', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Swiss Franc', 'eightshift-forms'), + 'selectOptionValue' => 'CHF', + 'selectOptionIsSelected' => $currency === 'CHF', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Canadian Dollar', 'eightshift-forms'), + 'selectOptionValue' => 'CAD', + 'selectOptionIsSelected' => $currency === 'CAD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Hungarian Forint', 'eightshift-forms'), + 'selectOptionValue' => 'HUF', + 'selectOptionIsSelected' => $currency === 'HUF', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Bahraini Dinar', 'eightshift-forms'), + 'selectOptionValue' => 'BHD', + 'selectOptionIsSelected' => $currency === 'BHD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Australian Dollar', 'eightshift-forms'), + 'selectOptionValue' => 'AUD', + 'selectOptionIsSelected' => $currency === 'AUD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Russian Ruble', 'eightshift-forms'), + 'selectOptionValue' => 'RUB', + 'selectOptionIsSelected' => $currency === 'RUB', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Polish Zloty', 'eightshift-forms'), + 'selectOptionValue' => 'PLN', + 'selectOptionIsSelected' => $currency === 'PLN', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Romanian Leu', 'eightshift-forms'), + 'selectOptionValue' => 'RON', + 'selectOptionIsSelected' => $currency === 'RON', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Czech Koruna', 'eightshift-forms'), + 'selectOptionValue' => 'CZK', + 'selectOptionIsSelected' => $currency === 'CZK', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Icelandic Krona', 'eightshift-forms'), + 'selectOptionValue' => 'ISK', + 'selectOptionIsSelected' => $currency === 'ISK', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Bosnia-Herzegovina Convertible Mark', 'eightshift-forms'), + 'selectOptionValue' => 'BAM', + 'selectOptionIsSelected' => $currency === 'BAM', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Serbian Dinar', 'eightshift-forms'), + 'selectOptionValue' => 'RSD', + 'selectOptionIsSelected' => $currency === 'RSD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Macedonian Denar', 'eightshift-forms'), + 'selectOptionValue' => 'MKD', + 'selectOptionIsSelected' => $currency === 'MKD', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Bulgarian Lev', 'eightshift-forms'), + 'selectOptionValue' => 'BGN', + 'selectOptionIsSelected' => $currency === 'BGN', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Albanian Lek', 'eightshift-forms'), + 'selectOptionValue' => 'ALL', + 'selectOptionIsSelected' => $currency === 'ALL', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Turkish Lira', 'eightshift-forms'), + 'selectOptionValue' => 'TRY', + 'selectOptionIsSelected' => $currency === 'TRY', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Israeli Shekel', 'eightshift-forms'), + 'selectOptionValue' => 'ILS', + 'selectOptionIsSelected' => $currency === 'ILS', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('United Arab Emirates Dirham', 'eightshift-forms'), + 'selectOptionValue' => 'AED', + 'selectOptionIsSelected' => $currency === 'AED', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Chinese Yuan', 'eightshift-forms'), + 'selectOptionValue' => 'CNY', + 'selectOptionIsSelected' => $currency === 'CNY', + ], + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Japanese Yen', 'eightshift-forms'), + 'selectOptionValue' => 'JPY', + 'selectOptionIsSelected' => $currency === 'JPY', + ], ], ], - ], - [ - 'component' => 'input', - 'inputIsRequired' => true, - 'inputName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_CART_DESC_KEY), - 'inputFieldLabel' => \__('Cart description', 'eightshift-forms'), - 'inputMaxLength' => 254, - 'inputFieldHelp' => \__('Shopping-cart contents description.', 'eightshift-forms'), - 'inputValue' => UtilsSettingsHelper::getSettingValue(self::SETTINGS_CORVUS_CART_DESC_KEY, $formId), - ], - [ - 'component' => 'checkboxes', - 'checkboxesFieldLabel' => '', - 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_REQ_COMPLETE_KEY), - 'checkboxesContent' => [ - [ - 'component' => 'checkbox', - 'checkboxLabel' => \__('Require complete', 'eightshift-forms'), - 'checkboxHelp' => \__('Checked indicates an preauthorization. None checked indicates a sale. Note: applicable only for card transactions.', 'eightshift-forms'), - 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, $formId), - 'checkboxValue' => self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, - 'checkboxAsToggle' => true, + [ + 'component' => 'input', + 'inputIsRequired' => true, + 'inputName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_CART_DESC_KEY), + 'inputFieldLabel' => \__('Cart description', 'eightshift-forms'), + 'inputMaxLength' => 254, + 'inputFieldHelp' => \__('Shopping-cart contents description.', 'eightshift-forms'), + 'inputValue' => UtilsSettingsHelper::getSettingValue(self::SETTINGS_CORVUS_CART_DESC_KEY, $formId), + ], + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_REQ_COMPLETE_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Require complete', 'eightshift-forms'), + 'checkboxHelp' => \__('Checked indicates an pre-authorization. Unchecked indicates a sale. Note: applicable only for card transactions.', 'eightshift-forms'), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, $formId), + 'checkboxValue' => self::SETTINGS_CORVUS_REQ_COMPLETE_KEY, + 'checkboxAsToggle' => true, + 'checkboxSingleSubmit' => true, + ] ] - ] - ], + ], + [ + 'component' => 'divider', + 'dividerExtraVSpacing' => true, + ], + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CORVUS_IBAN_USE_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Use IBAN Payment', 'eightshift-forms'), + 'checkboxHelp' => \__('To use IBAN Payment you must have this feature enabled in your Corvus account by contacting support.', 'eightshift-forms'), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CORVUS_IBAN_USE_KEY, self::SETTINGS_CORVUS_IBAN_USE_KEY, $formId), + 'checkboxValue' => self::SETTINGS_CORVUS_IBAN_USE_KEY, + 'checkboxAsToggle' => true, + 'checkboxSingleSubmit' => true, + ] + ] + ], + ] : []), ], ], ($selectedStoreId && $params) ? [ diff --git a/src/Integrations/Hubspot/HubspotClient.php b/src/Integrations/Hubspot/HubspotClient.php index 955c7102..5dfd3820 100644 --- a/src/Integrations/Hubspot/HubspotClient.php +++ b/src/Integrations/Hubspot/HubspotClient.php @@ -178,12 +178,11 @@ public function getContactProperties(): array foreach ($items as $item) { $name = $item['name'] ?? ''; $hidden = $item['hidden'] ?? false; - $readOnlyValue = $item['readOnlyValue'] ?? false; $formField = $item['formField'] ?? false; - $deleted = $item['deleted'] ?: false; // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + $archived = $item['archived'] ?? false; $fieldType = $item['fieldType'] ?? ''; - if (!$name || $hidden || $readOnlyValue || !$formField || $deleted) { + if (!$name || $hidden || !$formField || $archived) { continue; } @@ -269,7 +268,7 @@ public function postApplication(string $itemId, array $params, array $files, str $paramsFiles ); - $url = $this->getBaseUrl("submissions/v3/integration/secure/submit/{$baseId}/{$submitId}"); + $url = "https://api.hsforms.com/submissions/v3/integration/secure/submit/{$baseId}/{$submitId}"; // Not using getBaseUrl method because of different url only for this legacy endpoint. $response = \wp_remote_post( $url, @@ -329,10 +328,7 @@ public function postContactProperty(string $email, array $params): array continue; } - $properties[] = [ - 'property' => $key, - 'value' => $value, - ]; + $properties[$key] = $value; } } @@ -340,11 +336,12 @@ public function postContactProperty(string $email, array $params): array 'properties' => $properties, ]; - $url = $this->getBaseUrl("contacts/v1/contact/createOrUpdate/email/{$email}", true); + $url = $this->getBaseUrl("crm/v3/objects/contacts/{$email}?idProperty=email"); $response = \wp_remote_post( $url, [ + 'method' => 'PATCH', 'headers' => $this->getHeaders(), 'body' => \wp_json_encode($body), ] @@ -390,8 +387,12 @@ private function postFileMedia(string $file, string $formId): string $folder = self::HUBSPOT_FILEMANAGER_DEFAULT_FOLDER_KEY; } + $fileName = \pathinfo($file, \PATHINFO_FILENAME); + $fileExtension = \pathinfo($file, \PATHINFO_EXTENSION); + $options = [ 'folderPath' => '/' . $folder, + 'fileName' => "{$fileName}.{$fileExtension}", 'options' => \wp_json_encode([ "access" => "PUBLIC_NOT_INDEXABLE", "overwrite" => false, @@ -414,7 +415,7 @@ private function postFileMedia(string $file, string $formId): string \curl_setopt_array( // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_setopt_array $curl, [ - \CURLOPT_URL => $this->getBaseUrl("filemanager/api/v3/files/upload", true), + \CURLOPT_URL => $this->getBaseUrl("files/v3/files"), \CURLOPT_FAILONERROR => true, \CURLOPT_POST => true, \CURLOPT_RETURNTRANSFER => true, @@ -430,7 +431,7 @@ private function postFileMedia(string $file, string $formId): string if ($code >= UtilsConfig::API_RESPONSE_CODE_SUCCESS && $code <= UtilsConfig::API_RESPONSE_CODE_SUCCESS_RANGE) { $response = \json_decode((string) $response, true); - return $response['objects'][0]['url'] ?? ''; + return $response['url'] ?? ''; } return ''; @@ -551,7 +552,7 @@ private function getFieldsErrors(array $body): array */ private function getHubspotContactProperties() { - $url = $this->getBaseUrl('properties/v1/contacts/properties', true); + $url = $this->getBaseUrl('crm/v3/properties/contacts'); $response = \wp_remote_get( $url, @@ -574,7 +575,7 @@ private function getHubspotContactProperties() // On success return output. if ($code >= UtilsConfig::API_RESPONSE_CODE_SUCCESS && $code <= UtilsConfig::API_RESPONSE_CODE_SUCCESS_RANGE) { - return $body ?? []; + return $body['results'] ?? []; } return []; @@ -587,7 +588,7 @@ private function getHubspotContactProperties() */ public function getTestApi(): array { - $url = $this->getBaseUrl('forms/v2/forms', true); + $url = $this->getBaseUrl('forms/v2/forms'); $response = \wp_remote_get( $url, @@ -913,18 +914,11 @@ private function getApiKey(): string * Return HubSpot base url. * * @param string $path Path to append. - * @param bool $legacy If legacy use different url. * * @return string */ - private function getBaseUrl(string $path, bool $legacy = false): string + private function getBaseUrl(string $path): string { - $url = 'https://api.hsforms.com'; - - if ($legacy) { - $url = 'https://api.hubapi.com'; - } - - return "{$url}/{$path}"; + return "https://api.hubapi.com/{$path}"; } } diff --git a/src/Integrations/Hubspot/SettingsHubspot.php b/src/Integrations/Hubspot/SettingsHubspot.php index dd78a104..6a04e1fa 100644 --- a/src/Integrations/Hubspot/SettingsHubspot.php +++ b/src/Integrations/Hubspot/SettingsHubspot.php @@ -281,7 +281,7 @@ public function getSettingsGlobalData(): array \__('Click on the settings cog icon in the top right, next to your account.', 'eightshift-forms'), \__('In the menu on the left, under Integrations click Private Apps.', 'eightshift-forms'), \__('Click on Create a private app.', 'eightshift-forms'), - \__('Provide the app name and these scopes: forms, files, crm.objects.contacts.write, crm.schemas.custom.read.', 'eightshift-forms'), + \__('Provide the app name and these scopes: forms, files, crm.objects.contacts.read, crm.objects.contacts.write, crm.schemas.custom.read.', 'eightshift-forms'), \__('Copy the API key into the field below or use the global constant.', 'eightshift-forms'), ], ], diff --git a/src/Integrations/Talentlyft/SettingsTalentlyft.php b/src/Integrations/Talentlyft/SettingsTalentlyft.php index e681e55e..3c2b723c 100644 --- a/src/Integrations/Talentlyft/SettingsTalentlyft.php +++ b/src/Integrations/Talentlyft/SettingsTalentlyft.php @@ -16,6 +16,7 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; use EightshiftForms\Integrations\AbstractSettingsIntegrations; use EightshiftForms\Troubleshooting\SettingsFallbackDataInterface; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingInterface; use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; @@ -59,6 +60,11 @@ class SettingsTalentlyft extends AbstractSettingsIntegrations implements UtilsSe */ public const SETTINGS_TALENTLYFT_FILE_UPLOAD_LIMIT_KEY = 'talentlyft-file-upload-limit'; + /** + * List type key. + */ + public const SETTINGS_TALENTLYFT_LIST_TYPE_KEY = 'talentlyft-list-type'; + /** * File upload limit default. Defined in MB. */ @@ -190,6 +196,7 @@ public function getSettingsGlobalData(): array } $deactivateIntegration = UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_TALENTLYFT_SKIP_INTEGRATION_KEY, self::SETTINGS_TALENTLYFT_SKIP_INTEGRATION_KEY); + $selectedListType = \array_flip(\array_filter(\explode(UtilsConfig::DELIMITER, UtilsSettingsHelper::getOptionValue(self::SETTINGS_TALENTLYFT_LIST_TYPE_KEY)))); return [ UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), @@ -265,6 +272,25 @@ public function getSettingsGlobalData(): array 'inputMax' => 5, 'inputStep' => 1, ], + [ + 'component' => 'divider', + 'dividerExtraVSpacing' => true, + ], + [ + 'component' => 'select', + 'selectIsMultiple' => true, + 'selectName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_TALENTLYFT_LIST_TYPE_KEY), + 'selectFieldLabel' => \__('Additional statuses list', 'eightshift-forms'), + 'selectPlaceholder' => \__('Get additional jobs from other statuses. Use with caution!', 'eightshift-forms'), + 'selectContent' => [ + [ + 'component' => 'select-option', + 'selectOptionLabel' => \__('Internal', 'eightshift-forms'), + 'selectOptionValue' => 'internal', + 'selectOptionIsSelected' => isset($selectedListType['internal']), + ], + ], + ], ], ], $this->settingsFallback->getOutputGlobalFallback(SettingsTalentlyft::SETTINGS_TYPE_KEY), diff --git a/src/Integrations/Talentlyft/TalentlyftClient.php b/src/Integrations/Talentlyft/TalentlyftClient.php index 0ea8b977..8c12b9c9 100644 --- a/src/Integrations/Talentlyft/TalentlyftClient.php +++ b/src/Integrations/Talentlyft/TalentlyftClient.php @@ -285,33 +285,41 @@ public function getTestApi(): array */ private function getTalentlyftItems(): array { - $url = "{$this->getBaseUrl()}jobs?perPage=200&status=published"; // API limit is 200. + $statuses = \array_filter(\explode(UtilsConfig::DELIMITER, UtilsSettingsHelper::getOptionValue(SettingsTalentlyft::SETTINGS_TALENTLYFT_LIST_TYPE_KEY))); - $response = \wp_remote_get( - $url, - [ - 'headers' => $this->getHeaders(), - ] - ); + \array_unshift($statuses, 'published'); - // Structure response details. - $details = UtilsApiHelper::getIntegrationApiReponseDetails( - SettingsTalentlyft::SETTINGS_TYPE_KEY, - $response, - $url, - ); + $output = []; - $code = $details[UtilsConfig::IARD_CODE]; - $body = $details[UtilsConfig::IARD_BODY]; + foreach ($statuses as $status) { + $url = "{$this->getBaseUrl()}jobs?perPage=200&status={$status}"; // API limit is 200. - UtilsDeveloperHelper::setQmLogsOutput($details); + $response = \wp_remote_get( + $url, + [ + 'headers' => $this->getHeaders(), + ] + ); - // On success return output. - if ($code >= UtilsConfig::API_RESPONSE_CODE_SUCCESS && $code <= UtilsConfig::API_RESPONSE_CODE_SUCCESS_RANGE) { - return $body['Results'] ?? []; + // Structure response details. + $details = UtilsApiHelper::getIntegrationApiReponseDetails( + SettingsTalentlyft::SETTINGS_TYPE_KEY, + $response, + $url, + ); + + $code = $details[UtilsConfig::IARD_CODE]; + $body = $details[UtilsConfig::IARD_BODY]; + + UtilsDeveloperHelper::setQmLogsOutput($details); + + // On success return output. + if ($code >= UtilsConfig::API_RESPONSE_CODE_SUCCESS && $code <= UtilsConfig::API_RESPONSE_CODE_SUCCESS_RANGE) { + $output = \array_merge($output, $body['Results'] ?? []); + } } - return []; + return $output; } /** diff --git a/src/Rest/Routes/Integrations/Corvus/FormSubmitCorvusRoute.php b/src/Rest/Routes/Integrations/Corvus/FormSubmitCorvusRoute.php index 04342f8b..e5c19a28 100644 --- a/src/Rest/Routes/Integrations/Corvus/FormSubmitCorvusRoute.php +++ b/src/Rest/Routes/Integrations/Corvus/FormSubmitCorvusRoute.php @@ -130,7 +130,7 @@ protected function submitAction(array $formDetails) $this->labels->getLabel('corvusSuccess', $formId), [ UtilsHelper::getStateResponseOutputKey('processExternally') => [ - 'type' => 'GET', + 'type' => 'POST', 'url' => $this->getUrl($formId), 'params' => $params, ], @@ -167,14 +167,20 @@ private function prepareParams(array $mapParams, array $params, string $formId): $output[$key] = $param; } + $time = \time(); + $output['store_id'] = UtilsSettingsHelper::getSettingValue(SettingsCorvus::SETTINGS_CORVUS_STORE_ID, $formId); $output['version'] = '1.4'; // Corvus API version. $output['language'] = UtilsSettingsHelper::getSettingValue(SettingsCorvus::SETTINGS_CORVUS_LANG_KEY, $formId); - $output['require_complete'] = (string) UtilsSettingsHelper::isSettingCheckboxChecked(SettingsCorvus::SETTINGS_CORVUS_REQ_COMPLETE_KEY, SettingsCorvus::SETTINGS_CORVUS_REQ_COMPLETE_KEY, $formId); + $output['require_complete'] = UtilsSettingsHelper::isSettingCheckboxChecked(SettingsCorvus::SETTINGS_CORVUS_REQ_COMPLETE_KEY, SettingsCorvus::SETTINGS_CORVUS_REQ_COMPLETE_KEY, $formId) ? 'true' : 'false'; $output['currency'] = UtilsSettingsHelper::getSettingValue(SettingsCorvus::SETTINGS_CORVUS_CURRENCY_KEY, $formId); - $output['order_number'] = 'order_' . \time(); + $output['order_number'] = "order_{$time}"; $output['cart'] = UtilsSettingsHelper::getSettingValue(SettingsCorvus::SETTINGS_CORVUS_CART_DESC_KEY, $formId); + if (UtilsSettingsHelper::isSettingCheckboxChecked(SettingsCorvus::SETTINGS_CORVUS_IBAN_USE_KEY, SettingsCorvus::SETTINGS_CORVUS_IBAN_USE_KEY, $formId)) { + $output['creditor_reference'] = "HR00{$time}"; + } + \ksort($output); return $output; diff --git a/src/Rest/Routes/Settings/BulkRoute.php b/src/Rest/Routes/Settings/BulkRoute.php index c44c4e8b..52d5d291 100644 --- a/src/Rest/Routes/Settings/BulkRoute.php +++ b/src/Rest/Routes/Settings/BulkRoute.php @@ -442,13 +442,14 @@ private function duplicate(array $ids): array foreach ($ids as $id) { $title = \get_the_title($id); + $type = \get_post_type($id); if (!$title) { // translators: %s replaces form id. $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } - $export = $this->transfer->getExportForm((string) $id); + $export = $this->transfer->getExportCpt((string) $id, $type); $action = $this->transfer->getImportByFormArray($export, false); diff --git a/src/Rest/Routes/Settings/LocationsRoute.php b/src/Rest/Routes/Settings/LocationsRoute.php index b49e8f46..be0dc1f1 100644 --- a/src/Rest/Routes/Settings/LocationsRoute.php +++ b/src/Rest/Routes/Settings/LocationsRoute.php @@ -10,6 +10,7 @@ namespace EightshiftForms\Rest\Routes\Settings; +use EightshiftForms\CustomPostType\Result; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsApiHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; @@ -60,6 +61,16 @@ public function routeCallback(WP_REST_Request $request) $params = $this->prepareSimpleApiParams($request, $this->getMethods()); $id = $params['id'] ?? ''; + $usageType = $params['type'] ?? ''; + + switch ($usageType) { + case Result::POST_TYPE_SLUG: + $errorMsg = \esc_html__('Your result output is not used in any location!', 'eightshift-forms'); + break; + default: + $errorMsg = \esc_html__('Your form is not used in any location!', 'eightshift-forms'); + break; + } $type = UtilsGeneralHelper::getFormTypeById($id); @@ -70,10 +81,10 @@ public function routeCallback(WP_REST_Request $request) 'output' => Helpers::render( 'item-details', [ - 'items' => UtilsGeneralHelper::getBlockLocations($id), - 'type' => UtilsGeneralHelper::getFormTypeById($id), + 'items' => UtilsGeneralHelper::getBlockLocations($id, $usageType), + 'type' => $type, 'sectionClass' => Helpers::getComponent('admin-listing')['componentClass'], - 'emptyContent' => \esc_html__('Your form is not used in any location!', 'eightshift-forms'), + 'emptyContent' => $errorMsg, 'additionalAttributes' => [ UtilsHelper::getStateAttribute('adminIntegrationType') => $type, ], diff --git a/src/Rest/Routes/Settings/TransferRoute.php b/src/Rest/Routes/Settings/TransferRoute.php index aa258135..78e3df05 100644 --- a/src/Rest/Routes/Settings/TransferRoute.php +++ b/src/Rest/Routes/Settings/TransferRoute.php @@ -10,6 +10,7 @@ namespace EightshiftForms\Rest\Routes\Settings; +use EightshiftForms\CustomPostType\Result; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsApiHelper; use EightshiftForms\Transfer\SettingsTransfer; use EightshiftForms\Transfer\Transfer; @@ -93,6 +94,7 @@ public function routeCallback(WP_REST_Request $request) $output = [ Transfer::TYPE_GLOBAL_SETTINGS => [], Transfer::TYPE_FORMS => [], + Transfer::TYPE_RESULT_OUTPUTS => [], ]; switch ($type) { @@ -115,12 +117,31 @@ public function routeCallback(WP_REST_Request $request) $items = \explode(',', $items); - $output[Transfer::TYPE_FORMS] = $this->transfer->getExportForms($items); + $output[Transfer::TYPE_FORMS] = $this->transfer->getExportCpts($items); + $internalType = 'export'; + break; + case SettingsTransfer::TYPE_EXPORT_RESULT_OUTPUTS: + $items = $params['items'] ?? []; + + if (!$items) { + return \rest_ensure_response( + UtilsApiHelper::getApiErrorPublicOutput( + \esc_html__('Please click on the Result outputs you want to export.', 'eightshift-forms'), + [], + $debug + ) + ); + } + + $items = \explode(',', $items); + + $output[Transfer::TYPE_RESULT_OUTPUTS] = $this->transfer->getExportCpts($items, Result::POST_TYPE_SLUG); $internalType = 'export'; break; case SettingsTransfer::TYPE_EXPORT_ALL: $output[Transfer::TYPE_GLOBAL_SETTINGS] = $this->transfer->getExportGlobalSettings(); - $output[Transfer::TYPE_FORMS] = $this->transfer->getExportForms(); + $output[Transfer::TYPE_FORMS] = $this->transfer->getExportCpts(); + $output[Transfer::TYPE_RESULT_OUTPUTS] = $this->transfer->getExportCpts([], Result::POST_TYPE_SLUG); $internalType = 'export'; break; case SettingsTransfer::TYPE_IMPORT: diff --git a/src/ResultOutput/SettingsResultOutput.php b/src/ResultOutput/SettingsResultOutput.php deleted file mode 100644 index 073f20c3..00000000 --- a/src/ResultOutput/SettingsResultOutput.php +++ /dev/null @@ -1,122 +0,0 @@ -> - */ - public function getSettingsGlobalData(): array - { - if (!UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_USE_KEY, self::SETTINGS_USE_KEY)) { - return UtilsSettingsOutputHelper::getNoActiveFeature(); - } - - return [ - UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - [ - 'component' => 'tabs', - 'tabsContent' => [ - [ - 'component' => 'tab', - 'tabLabel' => \__('Internal storage', 'eightshift-forms'), - 'tabContent' => [ - [ - 'component' => 'intro', - 'introSubtitle' => \__('If you change these options make sure you resave your permalinks under settings > permalinks.', 'eightshift-forms'), - 'introIsHighlighted' => true, - 'introIsHighlightedImportant' => true, - ], - [ - '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.', 'eightshift-forms'), - 'inputType' => 'text', - 'inputPlaceholder' => Result::POST_TYPE_URL_SLUG, - 'inputValue' => UtilsSettingsHelper::getOptionValue(self::SETTINGS_GLOBAL_URL_PREFIX_KEY), - ], - ], - ], - ], - ], - ]; - } -} diff --git a/src/Transfer/SettingsTransfer.php b/src/Transfer/SettingsTransfer.php index 3b380a7a..049a8e46 100644 --- a/src/Transfer/SettingsTransfer.php +++ b/src/Transfer/SettingsTransfer.php @@ -11,6 +11,7 @@ namespace EightshiftForms\Transfer; use EightshiftForms\CustomPostType\Forms; +use EightshiftForms\CustomPostType\Result; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; @@ -52,7 +53,12 @@ class SettingsTransfer implements ServiceInterface, UtilsSettingGlobalInterface /** * Type export forms key. */ - public const TYPE_EXPORT_FORMS = 'export-forms'; + public const TYPE_EXPORT_FORMS = 'export-' . Forms::POST_TYPE_SLUG; + + /** + * Type export result outputs key. + */ + public const TYPE_EXPORT_RESULT_OUTPUTS = 'export-' . Result::POST_TYPE_SLUG; /** * Type export all key. @@ -174,7 +180,28 @@ public function getSettingsGlobalData(): array ], ], ], - $this->getFormsList(), + $this->getCptList(Forms::POST_TYPE_SLUG), + [ + 'component' => 'divider', + ], + [ + 'component' => 'card-inline', + 'cardInlineTitle' => \__('Result Outputs', 'eightshift-forms'), + 'cardInlineIcon' => UtilsHelper::getUtilsIcons('form'), + 'cardInlineRightContent' => [ + [ + 'component' => 'submit', + 'submitValue' => \__('Export selected', 'eightshift-forms'), + 'submitVariant' => 'outline', + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('migrationType') => self::TYPE_EXPORT_RESULT_OUTPUTS, + UtilsHelper::getStateAttribute('migrationExportItems') => '', + ], + 'additionalClass' => UtilsHelper::getStateSelectorAdmin('transfer'), + ], + ], + ], + $this->getCptList(Result::POST_TYPE_SLUG), ] ], ], @@ -292,12 +319,14 @@ public function getSettingsGlobalData(): array /** * Get form list. * + * @param string $postType Post type slug. + * * @return array */ - public function getFormsList(): array + private function getCptList($postType): array { $args = [ - 'post_type' => Forms::POST_TYPE_SLUG, + 'post_type' => $postType, 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, @@ -328,9 +357,11 @@ public function getFormsList(): array \wp_reset_postdata(); + $name = $postType === Forms::POST_TYPE_SLUG ? self::TYPE_EXPORT_FORMS : self::TYPE_EXPORT_RESULT_OUTPUTS; + return [ 'component' => 'checkboxes', - 'checkboxesName' => 'form', + 'checkboxesName' => $name, 'checkboxesContent' => $output, 'checkboxesFieldHideLabel' => true, ]; diff --git a/src/Transfer/Transfer.php b/src/Transfer/Transfer.php index 48b1631a..8c18e1f8 100644 --- a/src/Transfer/Transfer.php +++ b/src/Transfer/Transfer.php @@ -29,6 +29,11 @@ class Transfer implements TransferInterface */ public const TYPE_FORMS = 'forms'; + /** + * Type result outputs key. + */ + public const TYPE_RESULT_OUTPUTS = 'resultOutputs'; + /** * Export global settings. * @@ -48,16 +53,17 @@ public function getExportGlobalSettings(): array } /** - * Export forms with settings. + * Export Custom post types with settings. * * @param array $items Specify items to query. + * @param string $postType Specify post type to query. * * @return array> */ - public function getExportForms(array $items = []): array + public function getExportCpts(array $items = [], string $postType = Forms::POST_TYPE_SLUG): array { $args = [ - 'post_type' => Forms::POST_TYPE_SLUG, + 'post_type' => $postType, 'no_found_rows' => true, 'update_post_term_cache' => false, 'post_status' => 'any', @@ -105,16 +111,17 @@ public function getExportForms(array $items = []): array } /** - * Export one form with settings. + * Export one custom post type with settings. * * @param string $item Specify item id to query. + * @param string $postType Specify post type to query. * * @return array */ - public function getExportForm(string $item): array + public function getExportCpt(string $item, string $postType = Forms::POST_TYPE_SLUG): array { $args = [ - 'post_type' => Forms::POST_TYPE_SLUG, + 'post_type' => $postType, 'no_found_rows' => true, 'update_post_term_cache' => false, 'posts_per_page' => 1, // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page @@ -172,9 +179,10 @@ public function getImport(string $upload, bool $override): bool $globalSettings = $data[self::TYPE_GLOBAL_SETTINGS] ?? []; $forms = $data[self::TYPE_FORMS] ?? []; + $resultOutputs = $data[self::TYPE_RESULT_OUTPUTS] ?? []; // Bailout if both keys are missing. - if (!$globalSettings && !$forms) { + if (!$globalSettings && !$forms && !$resultOutputs) { return false; } @@ -224,6 +232,13 @@ public function getImport(string $upload, bool $override): bool } } + // Import result outputs. + if ($resultOutputs) { + foreach ($resultOutputs as $resultOutput) { + $this->getImportByFormArray($resultOutput, $override); + } + } + return true; } diff --git a/src/Transfer/TransferInterface.php b/src/Transfer/TransferInterface.php index 94a2ce72..c29ce717 100644 --- a/src/Transfer/TransferInterface.php +++ b/src/Transfer/TransferInterface.php @@ -10,6 +10,8 @@ namespace EightshiftForms\Transfer; +use EightshiftForms\CustomPostType\Forms; + /** * Interface for TransferInterface */ @@ -23,22 +25,24 @@ interface TransferInterface public function getExportGlobalSettings(): array; /** - * Export Forms with settings. + * Export Custom post types with settings. * * @param array $items Specify items to query. + * @param string $postType Specify post type to query. * * @return array> */ - public function getExportForms(array $items = []): array; + public function getExportCpts(array $items = [], string $postType = Forms::POST_TYPE_SLUG): array; /** - * Export one form with settings. + * Export one custom post type with settings. * * @param string $item Specify item id to query. + * @param string $postType Specify post type to query. * * @return array */ - public function getExportForm(string $item): array; + public function getExportCpt(string $item, string $postType = Forms::POST_TYPE_SLUG): array; /** * Import uploaded file.