| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FirePlugins Framework |
| 4 | - * @version 1.2.5 | |
| 4 | + * @version 1.1.69 | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2023 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | if (!function_exists('add_action')) |
| @@ -25,24 +25,16 @@ | ||
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | function firepluginsframework_getFrameworkVersion($dir) |
| 28 | 28 | { |
| 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 | 29 | $framework_file = 'framework.xml'; |
| 38 | - | |
| 30 | + | |
| 39 | 31 | $xmlFile = $dir . '/Framework/' . $framework_file; |
| 40 | - | |
| 32 | + | |
| 41 | 33 | /** |
| 42 | 34 | * On development the xml file is located in /framework/source/framework.xml. |
| 43 | 35 | * On final zip, the file will rest on /Framework/framework.xml. |
| 44 | - * | |
| 36 | + * | |
| 45 | 37 | * Thus the check below. |
| 46 | 38 | */ |
| 47 | 39 | $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source/' . $framework_file; |
| 48 | 40 | |
| @@ -53,9 +45,9 @@ | ||
| 53 | 45 | { |
| 54 | 46 | $xml = simplexml_load_file($xmlFile); |
| 55 | 47 | } |
| 56 | 48 | |
| 57 | - return ($versions[$dir] = isset($xml->version) ? (string) $xml->version : '1.0.0'); | |
| 49 | + return isset($xml->version) ? (string) $xml->version : '1.0.0'; | |
| 58 | 50 | } |
| 59 | 51 | } |
| 60 | 52 | |
| 61 | 53 | if (!function_exists('firepluginsframework_getFrameworkPriority')) |
| @@ -68,32 +60,30 @@ | ||
| 68 | 60 | * @return void |
| 69 | 61 | */ |
| 70 | 62 | function firepluginsframework_getFrameworkPriority($dir) |
| 71 | 63 | { |
| 72 | - static $priorities = []; | |
| 64 | + $id = PHP_INT_MAX; | |
| 73 | 65 | |
| 74 | - if (isset($priorities[$dir])) | |
| 66 | + $version = firepluginsframework_getFrameworkVersion($dir); | |
| 67 | + $version = array_map('intval', explode('.', $version)); | |
| 68 | + | |
| 69 | + for ($i = 0; $i < count($version); $i++) | |
| 75 | 70 | { |
| 76 | - return $priorities[$dir]; | |
| 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 | + } | |
| 77 | 83 | } |
| 78 | 84 | |
| 79 | - $version = firepluginsframework_getFrameworkVersion($dir); | |
| 80 | - $version = array_map('intval', array_pad(explode('.', $version), 3, 0)); | |
| 81 | - | |
| 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); | |
| 85 | + return $id; | |
| 96 | 86 | } |
| 97 | 87 | } |
| 98 | 88 | |
| 99 | 89 | /** |
| @@ -149,9 +139,9 @@ | ||
| 149 | 139 | |
| 150 | 140 | // Support URL |
| 151 | 141 | if (!defined('FPF_SUPPORT_URL')) |
| 152 | 142 | { |
| 153 | - define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact/'); | |
| 143 | + define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact'); | |
| 154 | 144 | } |
| 155 | 145 | |
| 156 | 146 | // Site Tower Endpoint |
| 157 | 147 | if (!defined('FPF_TOWER_ENDPOINT')) |
| @@ -182,8 +172,14 @@ | ||
| 182 | 172 | { |
| 183 | 173 | define('FPF_TEMPLATE_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'template/{{PLUGIN}}/{{TEMPLATE}}/{{LICENSE_KEY}}/{{SITE_URL}}/get'); |
| 184 | 174 | } |
| 185 | 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 | + | |
| 186 | 182 | /** |
| 187 | 183 | * Get License Version URL |
| 188 | 184 | */ |
| 189 | 185 | if (!defined('FPF_GET_LICENSE_VERSION_URL')) |
| @@ -198,8 +194,10 @@ | ||
| 198 | 194 | { |
| 199 | 195 | define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/'); |
| 200 | 196 | } |
| 201 | 197 | |
| 198 | + firepluginsframework_load_textdomain(dirname(__DIR__)); | |
| 199 | + | |
| 202 | 200 | // Now kick off the class autoloader. |
| 203 | 201 | spl_autoload_register( |
| 204 | 202 | /** |
| 205 | 203 | * Autoload classes |
| @@ -209,40 +207,44 @@ | ||
| 209 | 207 | * @return void |
| 210 | 208 | */ |
| 211 | 209 | function ($class) |
| 212 | 210 | { |
| 213 | - static $namespaces = null; | |
| 211 | + $base = dirname(__FILE__) . '/Inc/'; | |
| 214 | 212 | |
| 215 | - if ($namespaces === null) | |
| 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) | |
| 216 | 223 | { |
| 217 | - $base = dirname(__FILE__) . '/Inc/'; | |
| 218 | - | |
| 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 | - ]; | |
| 224 | + if (strpos($class, $key) === 0) | |
| 225 | + { | |
| 226 | + $found = true; | |
| 227 | + break; | |
| 228 | + } | |
| 226 | 229 | } |
| 227 | 230 | |
| 228 | - foreach ($namespaces as $prefix => $dir) | |
| 231 | + if (!$found) | |
| 229 | 232 | { |
| 230 | - if (strpos($class, $prefix) === 0) | |
| 231 | - { | |
| 232 | - $file = $dir . str_replace('\\', '/', substr($class, strlen($prefix))) . '.php'; | |
| 233 | + return; | |
| 234 | + } | |
| 235 | + | |
| 236 | + $class = firepluginsframework_fixClassBasedOnNamespace($namespaces, $class); | |
| 233 | 237 | |
| 234 | - if (file_exists($file)) | |
| 235 | - { | |
| 236 | - require_once $file; | |
| 237 | - } | |
| 238 | + $file = str_replace('\\', '/', $class) . '.php'; | |
| 238 | 239 | |
| 239 | - return; | |
| 240 | - } | |
| 240 | + if (file_exists($file)) | |
| 241 | + { | |
| 242 | + require_once $file; | |
| 241 | 243 | } |
| 242 | 244 | } |
| 243 | 245 | ); |
| 244 | - | |
| 246 | + | |
| 245 | 247 | // load once |
| 246 | 248 | if (FPF_LOADED == $priority) |
| 247 | 249 | { |
| 248 | 250 | /** |
| @@ -258,4 +260,41 @@ | ||
| 258 | 260 | do_action('fpf_admin_init'); |
| 259 | 261 | } |
| 260 | 262 | } |
| 261 | 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 | +} | |