| @@ -1,15 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FirePlugins Framework |
| 4 | - * @version 1.0.21 | |
| 4 | + * @version 1.1.132 | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2022 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2025 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,9 +25,9 @@ | ||
| 19 | 25 | * @return void |
| 20 | 26 | */ |
| 21 | 27 | function firepluginsframework_getFrameworkVersion($dir) |
| 22 | 28 | { |
| 23 | - $framework_file = '/framework.xml'; | |
| 29 | + $framework_file = 'framework.xml'; | |
| 24 | 30 | |
| 25 | 31 | $xmlFile = $dir . '/Framework/' . $framework_file; |
| 26 | 32 | |
| 27 | 33 | /** |
| @@ -29,9 +35,9 @@ | ||
| 29 | 35 | * On final zip, the file will rest on /Framework/framework.xml. |
| 30 | 36 | * |
| 31 | 37 | * Thus the check below. |
| 32 | 38 | */ |
| 33 | - $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source' . $framework_file; | |
| 39 | + $xmlFile = file_exists($xmlFile) ? $xmlFile : $dir . '/source/' . $framework_file; | |
| 34 | 40 | |
| 35 | 41 | $xml = []; |
| 36 | 42 | |
| 37 | 43 | // load XML file |
| @@ -54,14 +60,30 @@ | ||
| 54 | 60 | * @return void |
| 55 | 61 | */ |
| 56 | 62 | function firepluginsframework_getFrameworkPriority($dir) |
| 57 | 63 | { |
| 58 | - $max_int_size = PHP_INT_MAX; | |
| 64 | + $id = PHP_INT_MAX; | |
| 59 | 65 | |
| 60 | 66 | $version = firepluginsframework_getFrameworkVersion($dir); |
| 61 | - $version = str_replace('.', '', $version); | |
| 67 | + $version = array_map('intval', explode('.', $version)); | |
| 62 | 68 | |
| 63 | - return $max_int_size - (int) $version; | |
| 69 | + for ($i = 0; $i < count($version); $i++) | |
| 70 | + { | |
| 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 | + } | |
| 83 | + } | |
| 84 | + | |
| 85 | + return $id; | |
| 64 | 86 | } |
| 65 | 87 | } |
| 66 | 88 | |
| 67 | 89 | /** |
| @@ -68,9 +90,9 @@ | ||
| 68 | 90 | * Initialize the Framework |
| 69 | 91 | * |
| 70 | 92 | * @return void |
| 71 | 93 | */ |
| 72 | -add_action( 'init', function() | |
| 94 | +add_action('init', function() | |
| 73 | 95 | { |
| 74 | 96 | if (class_exists('\FPFramework\Framework')) |
| 75 | 97 | { |
| 76 | 98 | return; |
| @@ -75,17 +97,11 @@ | ||
| 75 | 97 | { |
| 76 | 98 | return; |
| 77 | 99 | } |
| 78 | 100 | |
| 79 | - if (!function_exists('add_action')) | |
| 80 | - { | |
| 81 | - // We are running outside of the context of WordPress. | |
| 82 | - return; | |
| 83 | - } | |
| 84 | - | |
| 85 | 101 | $version = firepluginsframework_getFrameworkVersion(dirname(__DIR__)); |
| 86 | 102 | $priority = firepluginsframework_getFrameworkPriority(dirname(__DIR__)); |
| 87 | - | |
| 103 | + | |
| 88 | 104 | // Framework priority |
| 89 | 105 | if (!defined('FPF_LOADED')) |
| 90 | 106 | { |
| 91 | 107 | define('FPF_LOADED', $priority); |
| @@ -102,8 +118,32 @@ | ||
| 102 | 118 | { |
| 103 | 119 | define('FPF_SITE_URL', 'https://www.fireplugins.com/'); |
| 104 | 120 | } |
| 105 | 121 | |
| 122 | + // Framework Folder Path | |
| 123 | + if (!defined('FPF_BASE_DIR')) | |
| 124 | + { | |
| 125 | + define('FPF_BASE_DIR', dirname(__DIR__)); | |
| 126 | + } | |
| 127 | + | |
| 128 | + // Framework Folder Path | |
| 129 | + if (!defined('FPF_DIR')) | |
| 130 | + { | |
| 131 | + define('FPF_DIR', plugin_dir_path(__FILE__) . 'Inc'); | |
| 132 | + } | |
| 133 | + | |
| 134 | + // Framework Layouts Folder Path | |
| 135 | + if (!defined('FPF_LAYOUTS_DIR')) | |
| 136 | + { | |
| 137 | + define('FPF_LAYOUTS_DIR', FPF_DIR . '/Layouts/'); | |
| 138 | + } | |
| 139 | + | |
| 140 | + // Support URL | |
| 141 | + if (!defined('FPF_SUPPORT_URL')) | |
| 142 | + { | |
| 143 | + define('FPF_SUPPORT_URL', FPF_SITE_URL . 'contact/'); | |
| 144 | + } | |
| 145 | + | |
| 106 | 146 | // Site Tower Endpoint |
| 107 | 147 | if (!defined('FPF_TOWER_ENDPOINT')) |
| 108 | 148 | { |
| 109 | 149 | define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/'); |
| @@ -108,33 +148,48 @@ | ||
| 108 | 148 | { |
| 109 | 149 | define('FPF_TOWER_ENDPOINT', FPF_SITE_URL . 'wp-json/tower/v1/'); |
| 110 | 150 | } |
| 111 | 151 | |
| 152 | + // The templates.fireplugins.com Site URL | |
| 153 | + if (!defined('FPF_TEMPLATES_SITE_URL')) | |
| 154 | + { | |
| 155 | + define('FPF_TEMPLATES_SITE_URL', 'https://templates.fireplugins.com/'); | |
| 156 | + } | |
| 157 | + | |
| 158 | + // Site Tower Endpoint | |
| 159 | + if (!defined('FPF_TEMPLATES_TOWER_ENDPOINT')) | |
| 160 | + { | |
| 161 | + define('FPF_TEMPLATES_TOWER_ENDPOINT', FPF_TEMPLATES_SITE_URL . 'wp-json/tower/v1/'); | |
| 162 | + } | |
| 163 | + | |
| 112 | 164 | // URL to retrieve templates |
| 113 | 165 | if (!defined('FPF_TEMPLATES_GET_URL')) |
| 114 | 166 | { |
| 115 | - define('FPF_TEMPLATES_GET_URL', FPF_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{SITE_URL}}/get'); | |
| 167 | + define('FPF_TEMPLATES_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'templates/{{PLUGIN}}/{{LICENSE_KEY}}/{{PLUGIN_VERSION}}/{{SITE_URL}}/get'); | |
| 116 | 168 | } |
| 117 | 169 | |
| 170 | + // URL to retrieve a template | |
| 171 | + if (!defined('FPF_TEMPLATE_GET_URL')) | |
| 172 | + { | |
| 173 | + define('FPF_TEMPLATE_GET_URL', FPF_TEMPLATES_TOWER_ENDPOINT . 'template/{{PLUGIN}}/{{TEMPLATE}}/{{LICENSE_KEY}}/{{SITE_URL}}/get'); | |
| 174 | + } | |
| 175 | + | |
| 118 | 176 | /** |
| 119 | 177 | * Get License Version URL |
| 120 | 178 | */ |
| 121 | - if (!defined( 'FPF_GET_LICENSE_VERSION_URL' )) { | |
| 122 | - define ( 'FPF_GET_LICENSE_VERSION_URL' , FPF_TOWER_ENDPOINT . 'plugins/get_version/'); | |
| 179 | + if (!defined('FPF_GET_LICENSE_VERSION_URL')) | |
| 180 | + { | |
| 181 | + define('FPF_GET_LICENSE_VERSION_URL', FPF_TOWER_ENDPOINT . 'plugins/get_version/'); | |
| 123 | 182 | } |
| 124 | 183 | |
| 125 | 184 | /** |
| 126 | 185 | * Plugin Changelog URL |
| 127 | 186 | */ |
| 128 | - if (!defined( 'FPF_PLUGIN_CHANGELOG_URL' )) { | |
| 129 | - define ( 'FPF_PLUGIN_CHANGELOG_URL' , FPF_SITE_URL . '%s/changelog/'); | |
| 187 | + if (!defined('FPF_PLUGIN_CHANGELOG_URL')) | |
| 188 | + { | |
| 189 | + define('FPF_PLUGIN_CHANGELOG_URL', FPF_SITE_URL . '%s/changelog/'); | |
| 130 | 190 | } |
| 131 | 191 | |
| 132 | - firepluginsframework_load_textdomain(dirname(__DIR__)); | |
| 133 | - | |
| 134 | - // Include helper functions. | |
| 135 | - require_once 'Inc/Framework.php'; | |
| 136 | - | |
| 137 | 192 | // Now kick off the class autoloader. |
| 138 | 193 | spl_autoload_register( |
| 139 | 194 | /** |
| 140 | 195 | * Autoload classes |
| @@ -147,10 +202,10 @@ | ||
| 147 | 202 | { |
| 148 | 203 | $base = dirname(__FILE__) . '/Inc/'; |
| 149 | 204 | |
| 150 | 205 | $namespaces = [ |
| 206 | + 'FPFramework\\GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ], | |
| 151 | 207 | 'FPFramework\\' => [ $base ], |
| 152 | - 'GeoIp2\\' => [ $base . 'Libs/Vendors/geoip2/geoip2/src/' ], | |
| 153 | 208 | 'MaxMind\\Db\\' => [ $base . 'Libs/Vendors/maxmind-db/reader/src/MaxMind/Db/' ], |
| 154 | 209 | 'MaxMind\\' => [ $base . 'Libs/Vendors/maxmind/web-service-common/src/' ], |
| 155 | 210 | 'splitbrain\\PHPArchive\\' => [$base . 'Libs/Vendors/splitbrain/php-archive/src/' ], |
| 156 | 211 | ]; |
| @@ -179,8 +234,10 @@ | ||
| 179 | 234 | require_once $file; |
| 180 | 235 | } |
| 181 | 236 | } |
| 182 | 237 | ); |
| 238 | + | |
| 239 | + \FPFramework\Base\Session::getInstance()->init(); | |
| 183 | 240 | |
| 184 | 241 | // load once |
| 185 | 242 | if (FPF_LOADED == $priority) |
| 186 | 243 | { |
| @@ -197,21 +254,8 @@ | ||
| 197 | 254 | do_action('fpf_admin_init'); |
| 198 | 255 | } |
| 199 | 256 | } |
| 200 | 257 | }, firepluginsframework_getFrameworkPriority(dirname(__DIR__))); |
| 201 | - | |
| 202 | -if (!function_exists('firepluginsframework_load_textdomain')) | |
| 203 | -{ | |
| 204 | - /** | |
| 205 | - * Load textdomain of plugin | |
| 206 | - * | |
| 207 | - * @return void | |
| 208 | - */ | |
| 209 | - function firepluginsframework_load_textdomain($dir) | |
| 210 | - { | |
| 211 | - load_plugin_textdomain('fp-framework', false, $dir . '/Framework/languages/'); | |
| 212 | - } | |
| 213 | -} | |
| 214 | 258 | |
| 215 | 259 | if (!function_exists('firepluginsframework_fixClassBasedOnNamespace')) |
| 216 | 260 | { |
| 217 | 261 | /** |