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 / Controllers / BoxSettings.php

BoxSettings.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.39, at Inc/Core/Controllers/BoxSettings.php

161 lines 3.7 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\Controllers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FPFramework\Base\Form;
20 use FPFramework\Base\FieldsParser;
21 use FPFramework\Base\Ui\Tabs;
22
23 class BoxSettings extends BaseController
24 {
25 protected $action = '';
26
27 /**
28 * The form settings name
29 *
30 * @var string
31 */
32 const settings_name = 'firebox_settings';
33
34 public function __construct()
35 {
36 add_action('update_option_firebox_settings', [$this, 'after_update_settings'], 10, 3);
37 }
38
39 /**
40 * Render the page content
41 *
42 * @return void
43 */
44 public function render()
45 {
46 // page content
47 add_action('firebox/settings_page', [$this, 'settingsPageContent']);
48
49 // render layout
50 firebox()->renderer->admin->render('pages/settings');
51 }
52
53 /**
54 * Stop the usage tracking if the user disables the tracking behavior.
55 *
56 * @param array $old_value
57 * @param array $new_value
58 *
59 * @return void
60 */
61 public function after_update_settings($old_value, $new_value)
62 {
63 if (isset($new_value['usage_tracking']) && !$new_value['usage_tracking'])
64 {
65 $tracking = new \FireBox\Core\UsageTracking\SendUsage();
66 $tracking->stop();
67 }
68 }
69
70 /**
71 * Load required media files
72 *
73 * @return void
74 */
75 public function addMedia()
76 {
77 // load geoip js
78 wp_register_script(
79 'fpf-geoip',
80 FPF_MEDIA_URL . 'admin/js/fpf_geoip.js',
81 [],
82 FPF_VERSION,
83 false
84 );
85 wp_enqueue_script('fpf-geoip');
86 }
87
88 /**
89 * Callback used to handle the processing of settings.
90 * Useful when using a Repeater field to remove the template from the list of submitted items.
91 *
92 * @param array $input
93 *
94 * @return void
95 */
96 public function processBoxSettings($input)
97 {
98 if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], ['firebox_download_key_notice_activate', 'firebox_enable_usage_tracking']))
99 {
100 return $input;
101 }
102
103 // run a quick security check
104 if (!check_admin_referer('fpf_form_nonce_firebox_settings', 'fpf_form_nonce_firebox_settings'))
105 {
106 return; // get out if we didn't click the Activate button
107 }
108
109 // Disable usage tracking
110 if (!isset($input['usage_tracking']))
111 {
112 $tracking = new \FireBox\Core\UsageTracking\SendUsage();
113 $tracking->stop();
114 }
115
116
117
118 // Filters the fields value
119 \FPFramework\Helpers\FormHelper::filterFields($input, \FireBox\Core\Admin\Forms\Settings::getSettings());
120
121 \FPFramework\Libs\AdminNotice::displaySuccess(fpframework()->_('FPF_SETTINGS_SAVED'));
122
123 return $input;
124 }
125
126
127
128 /**
129 * What the settings page will contain
130 *
131 * @return void
132 */
133 public function settingsPageContent()
134 {
135 $fieldsParser = new FieldsParser([
136 'fields_name_prefix' => 'firebox_settings'
137 ]);
138
139 $settings = \FireBox\Core\Admin\Forms\Settings::getSettings();
140 foreach ($settings['data'] as $key => $value)
141 {
142 ob_start();
143 $fieldsParser->renderContentFields($value);
144 $html = ob_get_contents();
145 ob_end_clean();
146
147 $settings['data'][$key]['title'] = $value['title'];
148 $settings['data'][$key]['content'] = $html;
149 }
150
151 // render settings as tabs
152 $tabs = new Tabs($settings);
153
154 // render form
155 $form = new Form($tabs->render(), [
156 'section_name' => self::settings_name
157 ]);
158
159 echo $form->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
160 }
161 }