PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.2
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.2
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.2, at Inc/Framework/init.php

222 lines 4.8 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.3
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2021 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 // Site Tower Endpoint
107 if (!defined('FPF_TOWER_ENDPOINT'))
108 {
109 define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/');
110 }
111
112 // URL to retrieve templates
113 if (!defined('FPF_TEMPLATES_GET_URL'))
114 {
115 define('FPF_TEMPLATES_GET_URL', FPF_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{SITE_URL}}/get');
116 }
117
118 /**
119 * Get License Version URL
120 */
121 if (!defined( 'FPF_GET_LICENSE_VERSION_URL' )) {
122 define ( 'FPF_GET_LICENSE_VERSION_URL' , FPF_TOWER_ENDPOINT . 'plugins/get_version/');
123 }
124
125 /**
126 * Plugin Changelog URL
127 */
128 if (!defined( 'FPF_PLUGIN_CHANGELOG_URL' )) {
129 define ( 'FPF_PLUGIN_CHANGELOG_URL' , FPF_SITE_URL . '%s/changelog/');
130 }
131
132 firepluginsframework_load_textdomain(dirname(__DIR__));
133
134 // Include helper functions.
135 require_once 'Inc/Framework.php';
136
137 // Now kick off the class autoloader.
138 spl_autoload_register(
139 /**
140 * Autoload classes
141 *
142 * @param string $class
143 *
144 * @return void
145 */
146 function ($class)
147 {
148 $base = dirname(__FILE__) . '/Inc/';
149
150 $namespaces = [
151 'FPFramework\\' => [ $base ],
152 'GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ],
153 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ],
154 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ],
155 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ],
156 ];
157
158 $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class);
159
160 $file = str_replace('\\', '/', $class) . '.php';
161
162 if (file_exists($file))
163 {
164 require_once $file;
165 }
166 }
167 );
168
169 // load once
170 if (FPF_LOADED == $priority)
171 {
172 /**
173 * Fires when FPFramework is included/loaded
174 */
175 do_action('fpf_init');
176
177 if (is_admin())
178 {
179 /**
180 * Fires on the admin side when FPFramework is included/loaded.
181 */
182 do_action('fpf_admin_init');
183 }
184 }
185 }, firepluginsframework_getFrameworkPriority(dirname(__DIR__)));
186
187 if (!function_exists('firepluginsframework_load_textdomain'))
188 {
189 /**
190 * Load textdomain of plugin
191 *
192 * @return void
193 */
194 function firepluginsframework_load_textdomain($dir)
195 {
196 load_plugin_textdomain('fp-framework', false, $dir . '/Framework/languages/');
197 }
198 }
199
200 if (!function_exists('firepluginsframework_fixClassBasedOnNamespace'))
201 {
202 /**
203 * Fixes the class paths
204 *
205 * @param string $namespaces
206 * @param string $class
207 *
208 * @return void
209 */
210 function firepluginsframework_fixClassBasedOnNamespace($namespaces, $class)
211 {
212 foreach ($namespaces as $key => $value)
213 {
214 if (strpos($class, $key) !== FALSE)
215 {
216 $class = str_replace($key, $value[0], $class);
217 }
218 }
219
220 return $class;
221 }
222 }