PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.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 / Controllers / BoxSettings.php

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

131 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 1.0.14 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 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 // create a unique db option to use it on all plugins to fetch the geo license key
75 $geo_license_key = '';
76 if (isset($input['geo_license_key']) && !empty($input['geo_license_key']))
77 {
78 $geo_license_key = $input['geo_license_key'];
79 }
80 update_option('fpf_geo_license_key', $geo_license_key);
81
82
83
84 // Filters the fields value
85 \FPFramework\Helpers\FormHelper::filterFields($input, \FireBox\Core\Admin\Forms\Settings::getSettings());
86
87 add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_SETTINGS_SAVED'), 'success');
88
89 return $input;
90 }
91
92
93
94 /**
95 * What the settings page will contain
96 *
97 * @return void
98 */
99 public function settingsPageContent()
100 {
101 $fieldsParser = new FieldsParser([
102 'fields_name_prefix' => 'firebox_settings'
103 ]);
104
105 $settings = \FireBox\Core\Admin\Forms\Settings::getSettings();
106 foreach ($settings['data'] as $key => $value)
107 {
108 ob_start();
109 $fieldsParser->renderContentFields($value);
110 $html = ob_get_contents();
111 ob_end_clean();
112
113 $settings['data'][$key]['title'] = $value['title'];
114 $settings['data'][$key]['content'] = $html;
115 }
116
117 // render settings as tabs
118 $tabs = new Tabs($settings);
119 ob_start();
120 $tabs->render();
121 $html = ob_get_contents();
122 ob_end_clean();
123
124 // render form
125 $form = new Form($html, [
126 'section_name' => self::settings_name,
127 'vertical' => true
128 ]);
129 $form->render();
130 }
131 }