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

134 lines 2.5 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.39 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2025 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 * Error message.
44 *
45 * @var string
46 */
47 private $error_message = '';
48
49 public function __construct($form_settings = [], $submission = [])
50 {
51 $this->form_settings = $form_settings;
52 $this->submission = $submission;
53 $this->field_values = $this->getSubmissionFieldValues();
54
55 $this->prepare();
56
57 $this->replaceSmartTags();
58 }
59
60 /**
61 * Runs once the action has been initialized.
62 *
63 * @return void
64 */
65 protected function prepare() {}
66
67 /**
68 * Validates the action prior to running it.
69 *
70 * @return void
71 */
72 public function validate() {}
73
74 /**
75 * Runs the action.
76 *
77 * @throws Exception
78 *
79 * @return void
80 */
81 public function run() {}
82
83 /**
84 * Returns the email value from the submission.
85 *
86 * @return string
87 */
88 protected function getEmailValue()
89 {
90 return isset($this->field_values['email']) ? $this->field_values['email'] : '';
91 }
92
93 /**
94 * Finds all field values from the submission.
95 *
96 * @return array
97 */
98 protected function getSubmissionFieldValues()
99 {
100 $prepared_fields = isset($this->submission['prepared_fields']) ? $this->submission['prepared_fields'] : [];
101 if (!$prepared_fields)
102 {
103 return [];
104 }
105
106 $values = [];
107
108 foreach ($prepared_fields as $field_name => $field)
109 {
110 $values[$field_name] = $field['value_raw'];
111 }
112
113 return $values;
114 }
115
116 /**
117 * Replaces the Smart Tags within the email payload.
118 *
119 * @return void
120 */
121 protected function replaceSmartTags()
122 {
123 // Replace Smart Tags
124 $tags = new \FPFramework\Base\SmartTags\SmartTags();
125
126 // register FB Smart Tags
127 $tags->register('\FireBox\Core\Form\SmartTags', FBOX_BASE_FOLDER . '/Inc/Core/Form/SmartTags', [
128 'field_values' => $this->field_values,
129 'submission' => $this->submission
130 ]);
131
132 $this->action_settings = $tags->replace($this->action_settings);
133 }
134 }