PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.0.6
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.0.6
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.0.6, at Inc/Core/Controllers/BoxSettings.php

130 lines 2.8 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.0.6 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2023 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 /**
26 * The form settings name
27 *
28 * @var string
29 */
30 const settings_name = 'firebox_settings';
31
32 /**
33 * Render the page content
34 *
35 * @return void
36 */
37 public function render()
38 {
39 // page content
40 add_action('firebox/settings_page', [$this, 'settingsPageContent']);
41
42 // render layout
43 firebox()->renderer->admin->render('pages/settings');
44 }
45
46 /**
47 * Load required media files
48 *
49 * @return void
50 */
51 public function addMedia()
52 {
53 // load geoip js
54 wp_register_script(
55 'fpf-geoip',
56 FPF_MEDIA_URL . 'admin/js/fpf_geoip.js',
57 [],
58 FPF_VERSION,
59 false
60 );
61 wp_enqueue_script('fpf-geoip');
62 }
63
64 /**
65 * Callback used to handle the processing of settings.
66 * Useful when using a Repeater field to remove the template from the list of submitted items.
67 *
68 * @param array $input
69 *
70 * @return void
71 */
72 public function processBoxSettings($input)
73 {
74 error_log(print_r($input, true));
75
76 // create a unique db option to use it on all plugins to fetch the geo license key
77 $geo_license_key = '';
78 if (isset($input['geo_license_key']) && !empty($input['geo_license_key']))
79 {
80 $geo_license_key = $input['geo_license_key'];
81 }
82 update_option('fpf_geo_license_key', $geo_license_key);
83
84
85
86 // Filters the fields value
87 \FPFramework\Helpers\FormHelper::filterFields($input, \FireBox\Core\Admin\Forms\Settings::getSettings());
88
89 add_settings_error(self::settings_name, 'settings_updated', fpframework()->_('FPF_SETTINGS_SAVED'), 'success');
90
91 return $input;
92 }
93
94
95
96 /**
97 * What the settings page will contain
98 *
99 * @return void
100 */
101 public function settingsPageContent()
102 {
103 $fieldsParser = new FieldsParser([
104 'fields_name_prefix' => 'firebox_settings'
105 ]);
106
107 $settings = \FireBox\Core\Admin\Forms\Settings::getSettings();
108 foreach ($settings['data'] as $key => $value)
109 {
110 ob_start();
111 $fieldsParser->renderContentFields($value);
112 $html = ob_get_contents();
113 ob_end_clean();
114
115 $settings['data'][$key]['title'] = $value['title'];
116 $settings['data'][$key]['content'] = $html;
117 }
118
119 // render settings as tabs
120 $tabs = new Tabs($settings);
121
122 // render form
123 $form = new Form($tabs->render(), [
124 'section_name' => self::settings_name,
125 'vertical' => true
126 ]);
127
128 echo$form->render();
129 }
130 }