PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.22
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.22
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 / Framework / init.php

init.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.22, at Inc/Framework/init.php

296 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FirePlugins Framework
4 * @version 1.1.116
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 if (!function_exists('add_action'))
13 {
14 // We are running outside of the context of WordPress.
15 return;
16 }
17
18 if (!function_exists('firepluginsframework_getFrameworkVersion'))
19 {
20 /**
21 * Return the framework version
22 *
23 * @param string $dir
24 *
25 * @return void
26 */
27 function firepluginsframework_getFrameworkVersion($dir)
28 {
29 $framework_file = 'framework.xml';
30
31 $xmlFile = $dir . '/Framework/' . $framework_file;
32
33 /**
34 * On development the xml file is located in /framework/source/framework.xml.
35 * On final zip, the file will rest on /Framework/framework.xml.
36 *
37 * Thus the check below.
38 */
39 $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source/' . $framework_file;
40
41 $xml = [];
42
43 // load XML file
44 if (function_exists('simplexml_load_file'))
45 {
46 $xml = simplexml_load_file($xmlFile);
47 }
48
49 return isset($xml->version) ? (string) $xml->version : '1.0.0';
50 }
51 }
52
53 if (!function_exists('firepluginsframework_getFrameworkPriority'))
54 {
55 /**
56 * Return the framework priority
57 *
58 * @param string $dir
59 *
60 * @return void
61 */
62 function firepluginsframework_getFrameworkPriority($dir)
63 {
64 $id = PHP_INT_MAX;
65
66 $version = firepluginsframework_getFrameworkVersion($dir);
67 $version = array_map('intval', explode('.', $version));
68
69 for ($i = 0; $i < count($version); $i++)
70 {
71 if ($i == 0)
72 {
73 $id -= $version[$i] * 105;
74 }
75 else if ($i == 1)
76 {
77 $id -= $version[$i] * 55;
78 }
79 else
80 {
81 $id -= $version[$i];
82 }
83 }
84
85 return $id;
86 }
87 }
88
89 /**
90 * Initialize the Framework
91 *
92 * @return void
93 */
94 add_action('init', function()
95 {
96 if (class_exists('\FPFramework\Framework'))
97 {
98 return;
99 }
100
101 $version = firepluginsframework_getFrameworkVersion(dirname(__DIR__));
102 $priority = firepluginsframework_getFrameworkPriority(dirname(__DIR__));
103
104 // Framework priority
105 if (!defined('FPF_LOADED'))
106 {
107 define('FPF_LOADED', $priority);
108 }
109
110 // Framework version
111 if (!defined('FPF_VERSION'))
112 {
113 define('FPF_VERSION', $version);
114 }
115
116 // Site URL
117 if (!defined('FPF_SITE_URL'))
118 {
119 define('FPF_SITE_URL', 'https://www.fireplugins.com/');
120 }
121
122 // Framework Folder Path
123 if (!defined('FPF_BASE_DIR'))
124 {
125 define('FPF_BASE_DIR', dirname(__DIR__));
126 }
127
128 // Framework Folder Path
129 if (!defined('FPF_DIR'))
130 {
131 define('FPF_DIR', plugin_dir_path(__FILE__) . 'Inc');
132 }
133
134 // Framework Layouts Folder Path
135 if (!defined('FPF_LAYOUTS_DIR'))
136 {
137 define('FPF_LAYOUTS_DIR', FPF_DIR . '/Layouts/');
138 }
139
140 // Support URL
141 if (!defined('FPF_SUPPORT_URL'))
142 {
143 define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact/');
144 }
145
146 // Site Tower Endpoint
147 if (!defined('FPF_TOWER_ENDPOINT'))
148 {
149 define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/');
150 }
151
152 // The templates.fireplugins.com Site URL
153 if (!defined('FPF_TEMPLATES_SITE_URL'))
154 {
155 define('FPF_TEMPLATES_SITE_URL', 'https://templates.fireplugins.com/');
156 }
157
158 // Site Tower Endpoint
159 if (!defined('FPF_TEMPLATES_TOWER_ENDPOINT'))
160 {
161 define('FPF_TEMPLATES_TOWER_ENDPOINT', FPF_TEMPLATES_SITE_URL . 'wp-json/tower/v1/');
162 }
163
164 // URL to retrieve templates
165 if (!defined('FPF_TEMPLATES_GET_URL'))
166 {
167 define('FPF_TEMPLATES_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{PLUGIN_VERSION}}/{{SITE_URL}}/get');
168 }
169
170 // URL to retrieve a template
171 if (!defined('FPF_TEMPLATE_GET_URL'))
172 {
173 define('FPF_TEMPLATE_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'template/{{PLUGIN}}/{{TEMPLATE}}/{{LICENSE_KEY}}/{{SITE_URL}}/get');
174 }
175
176 /**
177 * Get License Version URL
178 */
179 if (!defined('FPF_GET_LICENSE_VERSION_URL'))
180 {
181 define('FPF_GET_LICENSE_VERSION_URL', FPF_TOWER_ENDPOINT . 'plugins/get_version/');
182 }
183
184 /**
185 * Plugin Changelog URL
186 */
187 if (!defined('FPF_PLUGIN_CHANGELOG_URL'))
188 {
189 define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/');
190 }
191
192 firepluginsframework_load_textdomain(dirname(__DIR__));
193
194 // Now kick off the class autoloader.
195 spl_autoload_register(
196 /**
197 * Autoload classes
198 *
199 * @param string $class
200 *
201 * @return void
202 */
203 function ($class)
204 {
205 $base = dirname(__FILE__) . '/Inc/';
206
207 $namespaces = [
208 'FPFramework\\GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ],
209 'FPFramework\\' => [ $base ],
210 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ],
211 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ],
212 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ],
213 ];
214
215 $found = false;
216 foreach ($namespaces as $key => $value)
217 {
218 if (strpos($class, $key) === 0)
219 {
220 $found = true;
221 break;
222 }
223 }
224
225 if (!$found)
226 {
227 return;
228 }
229
230 $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class);
231
232 $file = str_replace('\\', '/', $class) . '.php';
233
234 if (file_exists($file))
235 {
236 require_once $file;
237 }
238 }
239 );
240
241 \FPFramework\Base\Session::getInstance()->init();
242
243 // load once
244 if (FPF_LOADED == $priority)
245 {
246 /**
247 * Fires when FPFramework is included/loaded
248 */
249 do_action('fpf_init');
250
251 if (is_admin())
252 {
253 /**
254 * Fires on the admin side when FPFramework is included/loaded.
255 */
256 do_action('fpf_admin_init');
257 }
258 }
259 }, firepluginsframework_getFrameworkPriority(dirname(__DIR__)));
260
261 if (!function_exists('firepluginsframework_load_textdomain'))
262 {
263 /**
264 * Load textdomain of plugin
265 *
266 * @return void
267 */
268 function firepluginsframework_load_textdomain($dir)
269 {
270 load_plugin_textdomain('fpf-framework', false, $dir . '/Framework/languages/');
271 }
272 }
273
274 if (!function_exists('firepluginsframework_fixClassBasedOnNamespace'))
275 {
276 /**
277 * Fixes the class paths
278 *
279 * @param string $namespaces
280 * @param string $class
281 *
282 * @return void
283 */
284 function firepluginsframework_fixClassBasedOnNamespace($namespaces, $class)
285 {
286 foreach ($namespaces as $key => $value)
287 {
288 if (strpos($class, $key) !== FALSE)
289 {
290 $class = str_replace($key, $value[0], $class);
291 }
292 }
293
294 return $class;
295 }
296 }