PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.15
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.15
6.2.15 6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 All 197 releases
← All changes | app/Services/Integrations/Slack/SlackNotificationActions.php +20 -23 3.6.62 → 6.2.15 View file →
@@ -1,10 +1,13 @@
1 1 <?php
2 2
3 3 namespace FluentForm\App\Services\Integrations\Slack;
4 4
5 +defined('ABSPATH') or die;
6 +
5 7 use FluentForm\App\Helpers\Helper;
6 8 use FluentForm\Framework\Foundation\Application;
9 +use FluentForm\Framework\Helpers\ArrayHelper as Arr;
7 10
8 11 class SlackNotificationActions
9 12 {
10 13 protected $app = null;
@@ -11,14 +14,14 @@
11 14
12 15 public function __construct(Application $app)
13 16 {
14 17 $this->app = $app;
15 -// add_filter('fluentform_notifying_async_slack', '__return_false');
18 +// add_filter('fluentform/notifying_async_slack', '__return_false');
16 19 }
17 20
18 21 public function register()
19 22 {
20 - add_filter('fluentform_global_notification_active_types', function ($types) {
23 + add_filter('fluentform/global_notification_active_types', function ($types) {
21 24 $isEnabled = Helper::isSlackEnabled();
22 25 if ($isEnabled) {
23 26 $types['slack'] = 'slack';
24 27 }
@@ -23,37 +26,31 @@
23 26 $types['slack'] = 'slack';
24 27 }
25 28 return $types;
26 29 });
27 - add_action('fluentform_integration_notify_slack', array($this, 'notify'), 20, 4);
30 + add_action('fluentform/integration_notify_slack', [$this, 'notify'], 20, 4);
31 + add_filter('fluentform/get_meta_key_settings_response', function ($response, $formId, $key) {
32 + if ('slack' == $key) {
33 + $formApi = fluentFormApi()->form($formId);
34 + $response['formattedFields'] = array_values($formApi->labels());
35 + }
36 +
37 + return $response;
38 + }, 10, 3);
28 39 }
29 40
30 41 public function notify($feed, $formData, $entry, $form)
31 42 {
32 43 $isEnabled = Helper::isSlackEnabled();
33 - if (!$isEnabled) {
44 + if (! $isEnabled) {
34 45 return;
35 46 }
36 47 $response = Slack::handle($feed, $formData, $form, $entry);
37 - if ($response['status'] === 'success') {
38 - do_action('ff_log_data', [
39 - 'parent_source_id' => $form->id,
40 - 'source_type' => 'submission_item',
41 - 'source_id' => $entry->id,
42 - 'component' => 'slack',
43 - 'status' => 'success',
44 - 'title' => $feed['meta_key'],
45 - 'description' => 'Slack feed has been successfully initialed and pushed data'
46 - ]);
48 + if ('success' === Arr::get($response, 'status')) {
49 + do_action('fluentform/integration_action_result', $feed, 'success',
50 + __('Slack feed has been successfully initialed and pushed data', 'fluentform'));
47 51 } else {
48 - do_action('ff_log_data', [
49 - 'parent_source_id' => $form->id,
50 - 'source_type' => 'submission_item',
51 - 'source_id' => $entry->id,
52 - 'component' => 'slack',
53 - 'status' => 'failed',
54 - 'title' => $feed['meta_key'],
55 - 'description' => $response['message']
56 - ]);
52 + $error = Arr::get($response, 'message');
53 + do_action('fluentform/integration_action_result', $feed, 'failed', $error);
57 54 }
58 55 }
59 56 }