PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / trunk
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder vtrunk
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
fluentform / app / Services / Integrations / Slack / SlackNotificationActions.php

SlackNotificationActions.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder trunk, at app/Services/Integrations/Slack/SlackNotificationActions.php

57 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Services\Integrations\Slack;
4
5 defined('ABSPATH') or die;
6
7 use FluentForm\App\Helpers\Helper;
8 use FluentForm\Framework\Foundation\Application;
9 use FluentForm\Framework\Helpers\ArrayHelper as Arr;
10
11 class SlackNotificationActions
12 {
13 protected $app = null;
14
15 public function __construct(Application $app)
16 {
17 $this->app = $app;
18 // add_filter('fluentform/notifying_async_slack', '__return_false');
19 }
20
21 public function register()
22 {
23 add_filter('fluentform/global_notification_active_types', function ($types) {
24 $isEnabled = Helper::isSlackEnabled();
25 if ($isEnabled) {
26 $types['slack'] = 'slack';
27 }
28 return $types;
29 });
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);
39 }
40
41 public function notify($feed, $formData, $entry, $form)
42 {
43 $isEnabled = Helper::isSlackEnabled();
44 if (! $isEnabled) {
45 return;
46 }
47 $response = Slack::handle($feed, $formData, $form, $entry);
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'));
51 } else {
52 $error = Arr::get($response, 'message');
53 do_action('fluentform/integration_action_result', $feed, 'failed', $error);
54 }
55 }
56 }
57