nitropack
Last commit date
classes
2 years ago
languages
2 years ago
nitropack-sdk
2 years ago
view
2 years ago
advanced-cache.php
2 years ago
batcache-compat.php
4 years ago
constants.php
2 years ago
diagnostics.php
2 years ago
functions.php
2 years ago
helpers.php
3 years ago
main.php
2 years ago
readme.txt
2 years ago
uninstall.php
2 years ago
wp-cli.php
2 years ago
constants.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
| 4 | |
| 5 | use \NitroPack\SDK\Filesystem; |
| 6 | |
| 7 | function nitropack_trailingslashit($string) { |
| 8 | return rtrim( $string, '/\\' ) . '/'; |
| 9 | } |
| 10 | |
| 11 | define( 'NITROPACK_VERSION', '1.15.2' ); |
| 12 | define( 'NITROPACK_OPTION_GROUP', 'nitropack' ); |
| 13 | define( 'NITROPACK_SLUG', 'nitropack' ); |
| 14 | define( 'NITROPACK_PLUGIN_DIR', nitropack_trailingslashit(dirname(__FILE__))); |
| 15 | define( 'NITROPACK_CLASSES_DIR', nitropack_trailingslashit(NITROPACK_PLUGIN_DIR . 'classes') ); |
| 16 | define( 'NITROPACK_HEARTBEAT_INTERVAL', 60*5); // 5min |
| 17 | define( 'NITROPACK_NONCE', 'np_nonce_' . NITROPACK_VERSION); |
| 18 | |
| 19 | if (!defined("NITROPACK_SUPPORT_BUBBLE_VISIBLE")) define("NITROPACK_SUPPORT_BUBBLE_VISIBLE", true); |
| 20 | if (!defined("NITROPACK_SUPPORT_BUBBLE_URL")) define("NITROPACK_SUPPORT_BUBBLE_URL", "https://support.nitropack.io/"); |
| 21 | |
| 22 | spl_autoload_register(function($class) { |
| 23 | $filename = str_replace("\\", "/", $class) . ".php"; |
| 24 | $filename = str_replace("NitroPack/", "", $filename); |
| 25 | $filepath = NITROPACK_CLASSES_DIR . ltrim($filename, "/"); |
| 26 | if (file_exists($filepath)) { |
| 27 | require_once $filepath; |
| 28 | } |
| 29 | }); |
| 30 | |
| 31 | if (!defined("NITROPACK_USE_REDIS")) define("NITROPACK_USE_REDIS", false); // Set this to true to enable storing cache in Redis |
| 32 | if (!defined("NITROPACK_REDIS_HOST")) define("NITROPACK_REDIS_HOST", "127.0.0.1"); // Set this to the IP of your Redis server |
| 33 | if (!defined("NITROPACK_REDIS_PORT")) define("NITROPACK_REDIS_PORT", 6379); // Set this to the port of your Redis server |
| 34 | if (!defined("NITROPACK_REDIS_PASS")) define("NITROPACK_REDIS_PASS", NULL); // Set this to the password of your redis server if authentication is needed |
| 35 | if (!defined("NITROPACK_REDIS_DB")) define("NITROPACK_REDIS_DB", NULL); // Set this to the number of the Redis DB if you'd like to not use the default one |
| 36 | |
| 37 | if (!defined("NITROPACK_CACHE_DIR_NAME")) define("NITROPACK_CACHE_DIR_NAME", substr(md5(__FILE__), 0, 7) . "-nitropack"); // IMPORTANT: If you are changing the pattern make sure to add it to the $oldNitroDirs array in NitroPack::getDataDir() |
| 38 | |
| 39 | define( 'NITROPACK_DATA_DIR', NitroPack\WordPress\NitroPack::getDataDir() ); |
| 40 | define( 'NITROPACK_PLUGIN_DATA_DIR', NitroPack\WordPress\NitroPack::getPluginDataDir() ); |
| 41 | define( 'NITROPACK_CONFIG_FILE', nitropack_trailingslashit(NITROPACK_PLUGIN_DATA_DIR) . 'config.json' ); |
| 42 | |
| 43 | if (Filesystem::fileExists(NITROPACK_CONFIG_FILE) && (NitroPack\WordPress\NitroPack::$nitroDirMigrated || NitroPack\WordPress\NitroPack::$nitroConfigMigrated)) { |
| 44 | // Update the config_path according to the new location of the file. |
| 45 | // Otherwise it will be ignored later and the plugin will appear disconnected. |
| 46 | (new NitroPack\WordPress\Config())->updateConfigPath(); |
| 47 | } |
| 48 | |
| 49 | add_action( 'plugins_loaded', function() { |
| 50 | define( 'NITROPACK_PLUGIN_DIR_URL', nitropack_trailingslashit( plugin_dir_url( __FILE__ ) )); |
| 51 | }, 1 ); |
| 52 | |
| 53 | if (!defined("NITROPACKIO_HOST")) { |
| 54 | $nitropackIo = getenv("NITROPACKIO_HOST"); |
| 55 | if (!$nitropackIo) { |
| 56 | $nitropackIo = "nitropack.io"; |
| 57 | } |
| 58 | define("NITROPACKIO_HOST", $nitropackIo); |
| 59 | } |