From 8d32b66245614c1a551477fd4cbf29eee730abc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 16 Dec 2024 12:50:26 +0100 Subject: [PATCH 1/3] fixed usage condition for the Clearbit cron job. --- CHANGELOG.md | 6 ++++++ eightshift-forms.php | 2 +- src/CronJobs/ClearbitJob.php | 14 +++++++------- src/Integrations/Clearbit/SettingsClearbit.php | 14 +++++--------- src/Integrations/Talentlyft/SettingsTalentlyft.php | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6229f5e6..6dc4db4a 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.6.4] + +### Fixed + +- Usage condition for Clearbit cron job. + ## [5.6.3] ### Fixed diff --git a/eightshift-forms.php b/eightshift-forms.php index b4fd46f0..848c1ebc 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.6.3 + * Version: 5.6.4 * Text Domain: eightshift-forms * * @package EightshiftForms diff --git a/src/CronJobs/ClearbitJob.php b/src/CronJobs/ClearbitJob.php index 91e82736..766644e9 100644 --- a/src/CronJobs/ClearbitJob.php +++ b/src/CronJobs/ClearbitJob.php @@ -66,13 +66,6 @@ public function __construct( */ public function register(): void { - $use = \apply_filters(SettingsClearbit::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false); - $useCron = UtilsSettingsHelper::isOptionCheckboxChecked(SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY, SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY); - - if (!$use || !$useCron) { - return; - } - \add_action('admin_init', [$this, 'checkIfJobIsSet']); \add_filter('cron_schedules', [$this, 'addJobToSchedule']); // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval \add_action(self::JOB_NAME, [$this, 'getJobCallback']); @@ -118,6 +111,13 @@ public function addJobToSchedule(array $schedules): array */ public function getJobCallback() { + $use = \apply_filters(SettingsClearbit::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false); + $useCron = UtilsSettingsHelper::isOptionCheckboxChecked(SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY, SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY); + + if (!$use || !$useCron) { + return; + } + $jobs = UtilsSettingsHelper::getOptionValueGroup(SettingsClearbit::SETTINGS_CLEARBIT_JOBS_KEY); if (!$jobs) { diff --git a/src/Integrations/Clearbit/SettingsClearbit.php b/src/Integrations/Clearbit/SettingsClearbit.php index 13921a0f..f710fc0b 100644 --- a/src/Integrations/Clearbit/SettingsClearbit.php +++ b/src/Integrations/Clearbit/SettingsClearbit.php @@ -110,7 +110,7 @@ public function register(): void { \add_filter(self::FILTER_SETTINGS_NAME, [$this, 'getSettingsData']); \add_filter(self::FILTER_SETTINGS_GLOBAL_NAME, [$this, 'getSettingsGlobalData']); - \add_filter(self::FILTER_SETTINGS_IS_VALID_NAME, [$this, 'isSettingsValid'], 10, 2); + \add_filter(self::FILTER_SETTINGS_IS_VALID_NAME, [$this, 'isSettingsValid']); \add_filter(self::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, [$this, 'isSettingsGlobalValid']); } @@ -118,13 +118,12 @@ public function register(): void * Determine if settings are valid. * * @param string $formId Form ID. - * @param string $type Integration type. * * @return boolean */ - public function isSettingsValid(string $formId, string $type): bool + public function isSettingsValid(string $formId): bool { - if (!$this->isSettingsGlobalValid($type)) { + if (!$this->isSettingsGlobalValid()) { return false; } @@ -140,17 +139,14 @@ public function isSettingsValid(string $formId, string $type): bool /** * Determine if settings global are valid. * - * @param string $type Integration type. - * * @return boolean */ - public function isSettingsGlobalValid(string $type = ''): bool + public function isSettingsGlobalValid(): bool { $isUsed = UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_CLEARBIT_USE_KEY, self::SETTINGS_CLEARBIT_USE_KEY); $apiKey = (bool) UtilsSettingsHelper::getSettingsDisabledOutputWithDebugFilter(Variables::getApiKeyClearbit(), self::SETTINGS_CLEARBIT_API_KEY_KEY)['value']; - $map = !empty($type) ? UtilsSettingsHelper::getOptionValueGroup(self::SETTINGS_CLEARBIT_MAP_HUBSPOT_KEYS_KEY . '-' . $type) : true; - if (!$isUsed || !$apiKey || !$map) { + if (!$isUsed || !$apiKey) { return false; } diff --git a/src/Integrations/Talentlyft/SettingsTalentlyft.php b/src/Integrations/Talentlyft/SettingsTalentlyft.php index 93922405..fa45f2e7 100644 --- a/src/Integrations/Talentlyft/SettingsTalentlyft.php +++ b/src/Integrations/Talentlyft/SettingsTalentlyft.php @@ -303,7 +303,7 @@ public function getSettingsGlobalData(): array 'stepsTitle' => \__('How to get the API key?', 'eightshift-forms'), 'stepsContent' => [ // translators: %s will be replaced with the link. - \sprintf(\__('Log in to your Talentlyft Account.', 'eightshift-forms'), 'https://app.talentlyft.io/'), + \sprintf(\__('Log in to your Talentlyft Account.', 'eightshift-forms'), 'https://app.talentlyft.com/'), // translators: %s will be replaced with the link. \sprintf(\__('Go to Integrations Settings.', 'eightshift-forms'), 'https://app.talentlyft.com/infinum/settings/integrations'), \__('Click on Settings under the TalentLyft card.', 'eightshift-forms'), From 20df763acd91b422070be08dc8846b990ae222b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 16 Dec 2024 12:51:19 +0100 Subject: [PATCH 2/3] fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dc4db4a..65eded29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -866,6 +866,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Initial production release. +[5.6.4]: https://github.com/infinum/eightshift-forms/compare/5.6.3...5.6.4 [5.6.3]: https://github.com/infinum/eightshift-forms/compare/5.6.2...5.6.3 [5.6.2]: https://github.com/infinum/eightshift-forms/compare/5.6.1...5.6.2 [5.6.1]: https://github.com/infinum/eightshift-forms/compare/5.6.0...5.6.1 From 4639c500a396ca572d832e083b97057a2e22c705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 16 Dec 2024 12:51:58 +0100 Subject: [PATCH 3/3] fix --- src/CronJobs/ClearbitJob.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/CronJobs/ClearbitJob.php b/src/CronJobs/ClearbitJob.php index 766644e9..5e55502c 100644 --- a/src/CronJobs/ClearbitJob.php +++ b/src/CronJobs/ClearbitJob.php @@ -113,14 +113,9 @@ public function getJobCallback() { $use = \apply_filters(SettingsClearbit::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, false); $useCron = UtilsSettingsHelper::isOptionCheckboxChecked(SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY, SettingsClearbit::SETTINGS_CLEARBIT_USE_JOBS_QUEUE_KEY); - - if (!$use || !$useCron) { - return; - } - $jobs = UtilsSettingsHelper::getOptionValueGroup(SettingsClearbit::SETTINGS_CLEARBIT_JOBS_KEY); - if (!$jobs) { + if (!$use || !$useCron || !$jobs) { return; }