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 / Framework / init.php

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

260 lines 5.4 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.0.27
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 if (!function_exists('firepluginsframework_getFrameworkVersion'))
13 {
14 /**
15 * Return the framework version
16 *
17 * @param string $dir
18 *
19 * @return void
20 */
21 function firepluginsframework_getFrameworkVersion($dir)
22 {
23 $framework_file = 'framework.xml';
24
25 $xmlFile = $dir . '/Framework/' . $framework_file;
26
27 /**
28 * On development the xml file is located in /framework/source/framework.xml.
29 * On final zip, the file will rest on /Framework/framework.xml.
30 *
31 * Thus the check below.
32 */
33 $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source/' . $framework_file;
34
35 $xml = [];
36
37 // load XML file
38 if (function_exists('simplexml_load_file'))
39 {
40 $xml = simplexml_load_file($xmlFile);
41 }
42
43 return isset($xml->version) ? (string) $xml->version : '1.0.0';
44 }
45 }
46
47 if (!function_exists('firepluginsframework_getFrameworkPriority'))
48 {
49 /**
50 * Return the framework priority
51 *
52 * @param string $dir
53 *
54 * @return void
55 */
56 function firepluginsframework_getFrameworkPriority($dir)
57 {
58 $max_int_size = PHP_INT_MAX;
59
60 $version = firepluginsframework_getFrameworkVersion($dir);
61 $version = str_replace('.', '', $version);
62
63 return $max_int_size - (int) $version;
64 }
65 }
66
67 /**
68 * Initialize the Framework
69 *
70 * @return void
71 */
72 add_action('init', function()
73 {
74 if (class_exists('\FPFramework\Framework'))
75 {
76 return;
77 }
78
79 if (!function_exists('add_action'))
80 {
81 // We are running outside of the context of WordPress.
82 return;
83 }
84
85 $version = firepluginsframework_getFrameworkVersion(dirname(__DIR__));
86 $priority = firepluginsframework_getFrameworkPriority(dirname(__DIR__));
87
88 // Framework priority
89 if (!defined('FPF_LOADED'))
90 {
91 define('FPF_LOADED', $priority);
92 }
93
94 // Framework version
95 if (!defined('FPF_VERSION'))
96 {
97 define('FPF_VERSION', $version);
98 }
99
100 // Site URL
101 if (!defined('FPF_SITE_URL'))
102 {
103 define('FPF_SITE_URL', 'https://www.fireplugins.com/');
104 }
105
106 // Framework Folder Path
107 if (!defined('FPF_BASE_DIR'))
108 {
109 define('FPF_BASE_DIR', dirname(__DIR__));
110 }
111
112 // Framework Folder Path
113 if (!defined('FPF_DIR'))
114 {
115 define('FPF_DIR', plugin_dir_path(__FILE__) . 'Inc');
116 }
117
118 // Framework Layouts Folder Path
119 if (!defined('FPF_LAYOUTS_DIR'))
120 {
121 define('FPF_LAYOUTS_DIR', FPF_DIR . '/Layouts/');
122 }
123
124 // Support URL
125 if (!defined('FPF_SUPPORT_URL'))
126 {
127 define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact');
128 }
129
130 // Site Tower Endpoint
131 if (!defined('FPF_TOWER_ENDPOINT'))
132 {
133 define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/');
134 }
135
136 // URL to retrieve templates
137 if (!defined('FPF_TEMPLATES_GET_URL'))
138 {
139 define('FPF_TEMPLATES_GET_URL', FPF_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{SITE_URL}}/get');
140 }
141
142 /**
143 * Get License Version URL
144 */
145 if (!defined('FPF_GET_LICENSE_VERSION_URL'))
146 {
147 define('FPF_GET_LICENSE_VERSION_URL', FPF_TOWER_ENDPOINT . 'plugins/get_version/');
148 }
149
150 /**
151 * Plugin Changelog URL
152 */
153 if (!defined('FPF_PLUGIN_CHANGELOG_URL'))
154 {
155 define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/');
156 }
157
158 firepluginsframework_load_textdomain(dirname(__DIR__));
159
160 // Now kick off the class autoloader.
161 spl_autoload_register(
162 /**
163 * Autoload classes
164 *
165 * @param string $class
166 *
167 * @return void
168 */
169 function ($class)
170 {
171 $base = dirname(__FILE__) . '/Inc/';
172
173 $namespaces = [
174 'FPFramework\\' => [ $base ],
175 'GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ],
176 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ],
177 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ],
178 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ],
179 ];
180
181 $found = false;
182 foreach ($namespaces as $key => $value)
183 {
184 if (strpos($class, $key) === 0)
185 {
186 $found = true;
187 break;
188 }
189 }
190
191 if (!$found)
192 {
193 return;
194 }
195
196 $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class);
197
198 $file = str_replace('\\', '/', $class) . '.php';
199
200 if (file_exists($file))
201 {
202 require_once $file;
203 }
204 }
205 );
206
207 // load once
208 if (FPF_LOADED == $priority)
209 {
210 /**
211 * Fires when FPFramework is included/loaded
212 */
213 do_action('fpf_init');
214
215 if (is_admin())
216 {
217 /**
218 * Fires on the admin side when FPFramework is included/loaded.
219 */
220 do_action('fpf_admin_init');
221 }
222 }
223 }, firepluginsframework_getFrameworkPriority(dirname(__DIR__)));
224
225 if (!function_exists('firepluginsframework_load_textdomain'))
226 {
227 /**
228 * Load textdomain of plugin
229 *
230 * @return void
231 */
232 function firepluginsframework_load_textdomain($dir)
233 {
234 load_plugin_textdomain('fpf-framework', false, $dir . '/Framework/languages/');
235 }
236 }
237
238 if (!function_exists('firepluginsframework_fixClassBasedOnNamespace'))
239 {
240 /**
241 * Fixes the class paths
242 *
243 * @param string $namespaces
244 * @param string $class
245 *
246 * @return void
247 */
248 function firepluginsframework_fixClassBasedOnNamespace($namespaces, $class)
249 {
250 foreach ($namespaces as $key => $value)
251 {
252 if (strpos($class, $key) !== FALSE)
253 {
254 $class = str_replace($key, $value[0], $class);
255 }
256 }
257
258 return $class;
259 }
260 }