PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.13
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.13
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 3.1.13, at Inc/Core/Form/Actions/Action.php

141 lines 2.6 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 3.1.13 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 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 * Submission.
30 *
31 * @var array
32 */
33 protected $submission = [];
34
35 /**
36 * Action settings.
37 *
38 * @var array
39 */
40 protected $action_settings = [];
41
42 /**
43 * Field values from the submission.
44 *
45 * @var array
46 */
47 protected $field_values = [];
48
49 /**
50 * Error message.
51 *
52 * @var string
53 */
54 private $error_message = '';
55
56 public function __construct($form_settings = [], $submission = [])
57 {
58 $this->form_settings = $form_settings;
59 $this->submission = $submission;
60 $this->field_values = $this->getSubmissionFieldValues();
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 * Validates the action prior to running it.
76 *
77 * @return void
78 */
79 public function validate() {}
80
81 /**
82 * Runs the action.
83 *
84 * @throws Exception
85 *
86 * @return void
87 */
88 public function run() {}
89
90 /**
91 * Returns the email value from the submission.
92 *
93 * @return string
94 */
95 protected function getEmailValue()
96 {
97 return isset($this->field_values['email']) ? $this->field_values['email'] : '';
98 }
99
100 /**
101 * Finds all field values from the submission.
102 *
103 * @return array
104 */
105 protected function getSubmissionFieldValues()
106 {
107 $prepared_fields = isset($this->submission['prepared_fields']) ? $this->submission['prepared_fields'] : [];
108 if (!$prepared_fields)
109 {
110 return [];
111 }
112
113 $values = [];
114
115 foreach ($prepared_fields as $field_name => $field)
116 {
117 $values[$field_name] = $field['value_raw'];
118 }
119
120 return $values;
121 }
122
123 /**
124 * Replaces the Smart Tags within the email payload.
125 *
126 * @return void
127 */
128 protected function replaceSmartTags()
129 {
130 // Replace Smart Tags
131 $tags = new \FPFramework\Base\SmartTags\SmartTags();
132
133 // register FB Smart Tags
134 $tags->register('\FireBox\Core\Form\SmartTags', FBOX_BASE_FOLDER . '/Inc/Core/Form/SmartTags', [
135 'field_values' => $this->field_values,
136 'submission' => $this->submission
137 ]);
138
139 $this->action_settings = $tags->replace($this->action_settings);
140 }
141 }