PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.31
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.31
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 3.6.65 All 196 releases
fluentform / app / Services / FormBuilder / Notifications / EmailNotificationActions.php

EmailNotificationActions.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.31, at app/Services/FormBuilder/Notifications/EmailNotificationActions.php

67 lines 2.1 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\FormBuilder\Notifications;
4
5 use FluentForm\Framework\Foundation\Application;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8 class EmailNotificationActions
9 {
10 protected $app = null;
11
12 public function __construct(Application $app)
13 {
14 $this->app = $app;
15 }
16
17 public function register()
18 {
19 add_filter('fluentform_notifying_async_email_notifications', '__return_false', 9);
20
21 add_filter('fluentform_global_notification_active_types', function ($types) {
22 $types['notifications'] = 'email_notifications';
23 return $types;
24 });
25
26 add_action('fluentform_integration_notify_notifications', array($this, 'notify'), 10, 4);
27 }
28
29 public function notify($feed, $formData, $entry, $form)
30 {
31 $notifier = $this->app->make(
32 'FluentForm\App\Services\FormBuilder\Notifications\EmailNotification'
33 );
34
35 $emailData = $feed['processedValues'];
36
37 $emailAttachments = [];
38 if(!empty($emailData['attachments']) && is_array($emailData['attachments'])) {
39 $attachments = [];
40 foreach ($emailData['attachments'] as $name) {
41 $fileUrls = ArrayHelper::get($formData, $name);
42 if($fileUrls && is_array($fileUrls)) {
43 foreach ($fileUrls as $url) {
44 $filePath = str_replace(
45 site_url(''),
46 wp_normalize_path( untrailingslashit( ABSPATH ) ),
47 $url
48 );
49 if(file_exists($filePath)) {
50 $attachments[] = $filePath;
51 }
52 }
53 }
54 }
55 $emailAttachments = $attachments;
56 }
57
58 // let others to apply attachments
59 $emailAttachments = apply_filters('fluentform_email_attachments', $emailAttachments, $emailData, $formData, $entry, $form);
60 if($emailAttachments) {
61 $emailData['attachments'] = $emailAttachments;
62 }
63
64 $notifier->notify($emailData, $formData, $form, $entry->id);
65 }
66 }
67