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

225 lines 4.9 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.1
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( 'firepluginsframework_autoload_classes' );
139
140 // load once
141 if (FPF_LOADED == $priority)
142 {
143 /**
144 * Fires when FPFramework is included/loaded
145 */
146 do_action('fpf_init');
147
148 if (is_admin())
149 {
150 /**
151 * Fires on the admin side when FPFramework is included/loaded.
152 */
153 do_action('fpf_admin_init');
154 }
155 }
156 }, 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 }