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

300 lines 6.3 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.83
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 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 // URL to check a license
177 if (!defined('FPF_CHECK_LICENSE'))
178 {
179 define('FPF_CHECK_LICENSE', 'https://www.fireplugins.com/wp-json/tower/v1/license/check/{{LICENSE}}/{{PLUGIN}}/{{SITE_URL}}');
180 }
181
182 /**
183 * Get License Version URL
184 */
185 if (!defined('FPF_GET_LICENSE_VERSION_URL'))
186 {
187 define('FPF_GET_LICENSE_VERSION_URL', FPF_TOWER_ENDPOINT . 'plugins/get_version/');
188 }
189
190 /**
191 * Plugin Changelog URL
192 */
193 if (!defined('FPF_PLUGIN_CHANGELOG_URL'))
194 {
195 define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/');
196 }
197
198 firepluginsframework_load_textdomain(dirname(__DIR__));
199
200 // Now kick off the class autoloader.
201 spl_autoload_register(
202 /**
203 * Autoload classes
204 *
205 * @param string $class
206 *
207 * @return void
208 */
209 function ($class)
210 {
211 $base = dirname(__FILE__) . '/Inc/';
212
213 $namespaces = [
214 'FPFramework\\' => [ $base ],
215 'GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ],
216 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ],
217 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ],
218 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ],
219 ];
220
221 $found = false;
222 foreach ($namespaces as $key => $value)
223 {
224 if (strpos($class, $key) === 0)
225 {
226 $found = true;
227 break;
228 }
229 }
230
231 if (!$found)
232 {
233 return;
234 }
235
236 $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class);
237
238 $file = str_replace('\\', '/', $class) . '.php';
239
240 if (file_exists($file))
241 {
242 require_once $file;
243 }
244 }
245 );
246
247 // load once
248 if (FPF_LOADED == $priority)
249 {
250 /**
251 * Fires when FPFramework is included/loaded
252 */
253 do_action('fpf_init');
254
255 if (is_admin())
256 {
257 /**
258 * Fires on the admin side when FPFramework is included/loaded.
259 */
260 do_action('fpf_admin_init');
261 }
262 }
263 }, firepluginsframework_getFrameworkPriority(dirname(__DIR__)));
264
265 if (!function_exists('firepluginsframework_load_textdomain'))
266 {
267 /**
268 * Load textdomain of plugin
269 *
270 * @return void
271 */
272 function firepluginsframework_load_textdomain($dir)
273 {
274 load_plugin_textdomain('fpf-framework', false, $dir . '/Framework/languages/');
275 }
276 }
277
278 if (!function_exists('firepluginsframework_fixClassBasedOnNamespace'))
279 {
280 /**
281 * Fixes the class paths
282 *
283 * @param string $namespaces
284 * @param string $class
285 *
286 * @return void
287 */
288 function firepluginsframework_fixClassBasedOnNamespace($namespaces, $class)
289 {
290 foreach ($namespaces as $key => $value)
291 {
292 if (strpos($class, $key) !== FALSE)
293 {
294 $class = str_replace($key, $value[0], $class);
295 }
296 }
297
298 return $class;
299 }
300 }