PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.14
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / Form / Actions / Action.php

Action.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.14, at Inc/Core/Form/Actions/Action.php

128 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 2.1.14 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Form\Actions;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Action
20 {
21 /**
22 * Form settings.
23 *
24 * @var array
25 */
26 protected $form_settings = [];
27
28 /**
29 * Fields values.
30 *
31 * @var array
32 */
33 protected $field_values = [];
34
35 /**
36 * Submission.
37 *
38 * @var array
39 */
40 protected $submission = [];
41
42 /**
43 * Action settings.
44 *
45 * @var array
46 */
47 protected $action_settings = [];
48
49 /**
50 * Error message.
51 *
52 * @var string
53 */
54 private $error_message = '';
55
56 public function __construct($form_settings = [], $field_values = [], $submission = [])
57 {
58 $this->form_settings = $form_settings;
59 $this->field_values = $field_values;
60 $this->submission = $submission;
61
62 $this->prepare();
63
64 $this->replaceSmartTags();
65 }
66
67 /**
68 * Runs once the action has been initialized.
69 *
70 * @return void
71 */
72 protected function prepare()
73 {}
74
75 /**
76 * Validates the action prior to running it.
77 *
78 * @return void
79 */
80 public function validate()
81 {}
82
83 /**
84 * Runs the action.
85 *
86 * @throws Exception
87 *
88 * @return void
89 */
90 public function run()
91 {}
92
93 /**
94 * Returns the fields values in a key,value array pair.
95 *
96 * @return array
97 */
98 protected function getParsedFieldValues()
99 {
100 $parsed = [];
101
102 foreach ($this->field_values as $key => $value)
103 {
104 $parsed[$key] = $value['value'];
105 }
106
107 return $parsed;
108 }
109
110 /**
111 * Replaces the Smart Tags within the email payload.
112 *
113 * @return void
114 */
115 protected function replaceSmartTags()
116 {
117 // Replace Smart Tags
118 $tags = new \FPFramework\Base\SmartTags\SmartTags();
119
120 // register FB Smart Tags
121 $tags->register('\FireBox\Core\Form\SmartTags', FBOX_BASE_FOLDER . '/Inc/Core/Form/SmartTags', [
122 'field_values' => $this->field_values,
123 'submission' => $this->submission
124 ]);
125
126 $this->action_settings = $tags->replace($this->action_settings);
127 }
128 }