PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.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 All 123 releases
← All changes | Inc/Framework/init.php +135 -99 1.0.1 → 3.1.14 View file →
@@ -1,15 +1,21 @@
1 1 <?php
2 2 /**
3 3 * @package FirePlugins Framework
4 - * @version 1.0.1
4 + * @version 1.2.6
5 5 *
6 6 * @author FirePlugins <[email protected]>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2021 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 +if (!function_exists('add_action'))
13 +{
14 + // We are running outside of the context of WordPress.
15 + return;
16 +}
17 +
12 18 if (!function_exists('firepluginsframework_getFrameworkVersion'))
13 19 {
14 20 /**
15 21 * Return the framework version
@@ -19,19 +25,27 @@
19 25 * @return void
20 26 */
21 27 function firepluginsframework_getFrameworkVersion($dir)
22 28 {
23 - $framework_file = '/framework.xml';
24 -
29 + // Memoize the parsed framework.xml per directory so it is only parsed once per request.
30 + static $versions = [];
31 +
32 + if (isset($versions[$dir]))
33 + {
34 + return $versions[$dir];
35 + }
36 +
37 + $framework_file = 'framework.xml';
38 +
25 39 $xmlFile = $dir . '/Framework/' . $framework_file;
26 -
40 +
27 41 /**
28 42 * On development the xml file is located in /framework/source/framework.xml.
29 43 * On final zip, the file will rest on /Framework/framework.xml.
30 - *
44 + *
31 45 * Thus the check below.
32 46 */
33 - $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source' . $framework_file;
47 + $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source/' . $framework_file;
34 48
35 49 $xml = [];
36 50
37 51 // load XML file
@@ -39,9 +53,9 @@
39 53 {
40 54 $xml = simplexml_load_file($xmlFile);
41 55 }
42 56
43 - return isset($xml->version) ? (string) $xml->version : '1.0.0';
57 + return ($versions[$dir] = isset($xml->version) ? (string) $xml->version : '1.0.0');
44 58 }
45 59 }
46 60
47 61 if (!function_exists('firepluginsframework_getFrameworkPriority'))
@@ -54,14 +68,32 @@
54 68 * @return void
55 69 */
56 70 function firepluginsframework_getFrameworkPriority($dir)
57 71 {
58 - $max_int_size = PHP_INT_MAX;
72 + static $priorities = [];
59 73
74 + if (isset($priorities[$dir]))
75 + {
76 + return $priorities[$dir];
77 + }
78 +
60 79 $version = firepluginsframework_getFrameworkVersion($dir);
61 - $version = str_replace('.', '', $version);
80 + $version = array_map('intval', array_pad(explode('.', $version), 3, 0));
62 81
63 - return $max_int_size - (int) $version;
82 + /**
83 + * Order the bundled frameworks so the newest one always registers first.
84 + *
85 + * Each component is weighted so it can never be outranked by the components below it.
86 + * The previous weights (105 / 55 / 1) let the patch number outgrow a minor bump, so
87 + * 1.1.150 loaded ahead of 1.2.0 and the older framework won.
88 + *
89 + * Bundles still shipping those weights produce offsets in the low hundreds, so any
90 + * bundle using the weights below outranks them. That is the correct outcome, as every
91 + * such bundle is by definition newer than the ones using the old weights.
92 + */
93 + $id = PHP_INT_MAX - (($version[0] * 1000000) + ($version[1] * 1000) + $version[2]);
94 +
95 + return ($priorities[$dir] = $id);
64 96 }
65 97 }
66 98
67 99 /**
@@ -68,9 +100,9 @@
68 100 * Initialize the Framework
69 101 *
70 102 * @return void
71 103 */
72 -add_action( 'init', function()
104 +add_action('init', function()
73 105 {
74 106 if (class_exists('\FPFramework\Framework'))
75 107 {
76 108 return;
@@ -75,17 +107,11 @@
75 107 {
76 108 return;
77 109 }
78 110
79 - if (!function_exists('add_action'))
80 - {
81 - // We are running outside of the context of WordPress.
82 - return;
83 - }
84 -
85 111 $version = firepluginsframework_getFrameworkVersion(dirname(__DIR__));
86 112 $priority = firepluginsframework_getFrameworkPriority(dirname(__DIR__));
87 -
113 +
88 114 // Framework priority
89 115 if (!defined('FPF_LOADED'))
90 116 {
91 117 define('FPF_LOADED', $priority);
@@ -102,8 +128,32 @@
102 128 {
103 129 define('FPF_SITE_URL', 'https://www.fireplugins.com/');
104 130 }
105 131
132 + // Framework Folder Path
133 + if (!defined('FPF_BASE_DIR'))
134 + {
135 + define('FPF_BASE_DIR', dirname(__DIR__));
136 + }
137 +
138 + // Framework Folder Path
139 + if (!defined('FPF_DIR'))
140 + {
141 + define('FPF_DIR', plugin_dir_path(__FILE__) . 'Inc');
142 + }
143 +
144 + // Framework Layouts Folder Path
145 + if (!defined('FPF_LAYOUTS_DIR'))
146 + {
147 + define('FPF_LAYOUTS_DIR', FPF_DIR . '/Layouts/');
148 + }
149 +
150 + // Support URL
151 + if (!defined('FPF_SUPPORT_URL'))
152 + {
153 + define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact/');
154 + }
155 +
106 156 // Site Tower Endpoint
107 157 if (!defined('FPF_TOWER_ENDPOINT'))
108 158 {
109 159 define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/');
@@ -108,36 +158,91 @@
108 158 {
109 159 define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/');
110 160 }
111 161
162 + // The templates.fireplugins.com Site URL
163 + if (!defined('FPF_TEMPLATES_SITE_URL'))
164 + {
165 + define('FPF_TEMPLATES_SITE_URL', 'https://templates.fireplugins.com/');
166 + }
167 +
168 + // Site Tower Endpoint
169 + if (!defined('FPF_TEMPLATES_TOWER_ENDPOINT'))
170 + {
171 + define('FPF_TEMPLATES_TOWER_ENDPOINT', FPF_TEMPLATES_SITE_URL . 'wp-json/tower/v1/');
172 + }
173 +
112 174 // URL to retrieve templates
113 175 if (!defined('FPF_TEMPLATES_GET_URL'))
114 176 {
115 - define('FPF_TEMPLATES_GET_URL', FPF_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{SITE_URL}}/get');
177 + define('FPF_TEMPLATES_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{PLUGIN_VERSION}}/{{SITE_URL}}/get');
116 178 }
117 179
180 + // URL to retrieve a template
181 + if (!defined('FPF_TEMPLATE_GET_URL'))
182 + {
183 + define('FPF_TEMPLATE_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'template/{{PLUGIN}}/{{TEMPLATE}}/{{LICENSE_KEY}}/{{SITE_URL}}/get');
184 + }
185 +
118 186 /**
119 187 * Get License Version URL
120 188 */
121 - if (!defined( 'FPF_GET_LICENSE_VERSION_URL' )) {
122 - define ( 'FPF_GET_LICENSE_VERSION_URL' , FPF_TOWER_ENDPOINT . 'plugins/get_version/');
189 + if (!defined('FPF_GET_LICENSE_VERSION_URL'))
190 + {
191 + define('FPF_GET_LICENSE_VERSION_URL', FPF_TOWER_ENDPOINT . 'plugins/get_version/');
123 192 }
124 193
125 194 /**
126 195 * Plugin Changelog URL
127 196 */
128 - if (!defined( 'FPF_PLUGIN_CHANGELOG_URL' )) {
129 - define ( 'FPF_PLUGIN_CHANGELOG_URL' , FPF_SITE_URL . '%s/changelog/');
197 + if (!defined('FPF_PLUGIN_CHANGELOG_URL'))
198 + {
199 + define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/');
130 200 }
131 201
132 - firepluginsframework_load_textdomain(dirname(__DIR__));
202 + // Now kick off the class autoloader.
203 + spl_autoload_register(
204 + /**
205 + * Autoload classes
206 + *
207 + * @param string $class
208 + *
209 + * @return void
210 + */
211 + function ($class)
212 + {
213 + static $namespaces = null;
133 214
134 - // Include helper functions.
135 - require_once 'Inc/Framework.php';
215 + if ($namespaces === null)
216 + {
217 + $base = dirname(__FILE__) . '/Inc/';
136 218
137 - // Now kick off the class autoloader.
138 - spl_autoload_register( 'firepluginsframework_autoload_classes' );
139 -
219 + $namespaces = [
220 + 'FPFramework\\GeoIp2\\' => $base . 'Libs/Vendors/geoip2/geoip2/src/',
221 + 'FPFramework\\' => $base,
222 + 'MaxMind\\Db\\' => $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/',
223 + 'MaxMind\\' => $base . 'Libs/Vendors/maxmind/web-service-common/src/',
224 + 'splitbrain\\PHPArchive\\' => $base . 'Libs/Vendors/splitbrain/php-archive/src/',
225 + ];
226 + }
227 +
228 + foreach ($namespaces as $prefix => $dir)
229 + {
230 + if (strpos($class, $prefix) === 0)
231 + {
232 + $file = $dir . str_replace('\\', '/', substr($class, strlen($prefix))) . '.php';
233 +
234 + if (file_exists($file))
235 + {
236 + require_once $file;
237 + }
238 +
239 + return;
240 + }
241 + }
242 + }
243 + );
244 +
140 245 // load once
141 246 if (FPF_LOADED == $priority)
142 247 {
143 248 /**
@@ -153,73 +258,4 @@
153 258 do_action('fpf_admin_init');
154 259 }
155 260 }
156 261 }, firepluginsframework_getFrameworkPriority(dirname(__DIR__)));
157 -
158 -if (!function_exists('firepluginsframework_autoload_classes'))
159 -{
160 - /**
161 - * Autoload classes
162 - *
163 - * @param string $class
164 - *
165 - * @return void
166 - */
167 - function firepluginsframework_autoload_classes($class)
168 - {
169 - $base = dirname(__FILE__) . '/Inc/';
170 -
171 - $namespaces = [
172 - 'FPFramework\\' => [ $base ],
173 - 'GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ],
174 - 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ],
175 - 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ],
176 - 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ],
177 - ];
178 -
179 - $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class);
180 -
181 - $file = str_replace('\\', '/', $class) . '.php';
182 -
183 - if (file_exists($file))
184 - {
185 - require_once $file;
186 - }
187 - }
188 -}
189 -
190 -if (!function_exists('firepluginsframework_load_textdomain'))
191 -{
192 - /**
193 - * Load textdomain of plugin
194 - *
195 - * @return void
196 - */
197 - function firepluginsframework_load_textdomain($dir)
198 - {
199 - load_plugin_textdomain('fp-framework', false, $dir . '/Framework/languages/');
200 - }
201 -}
202 -
203 -if (!function_exists('firepluginsframework_fixClassBasedOnNamespace'))
204 -{
205 - /**
206 - * Fixes the class paths
207 - *
208 - * @param string $namespaces
209 - * @param string $class
210 - *
211 - * @return void
212 - */
213 - function firepluginsframework_fixClassBasedOnNamespace($namespaces, $class)
214 - {
215 - foreach ($namespaces as $key => $value)
216 - {
217 - if (strpos($class, $key) !== FALSE)
218 - {
219 - $class = str_replace($key, $value[0], $class);
220 - }
221 - }
222 -
223 - return $class;
224 - }
225 -}