Closte.php
4 years ago
Cloudways.php
4 years ago
DreamHost.php
3 years ago
Flywheel.php
4 years ago
GoDaddyWPaaS.php
4 years ago
GridPane.php
4 years ago
Hosting.php
4 years ago
Kinsta.php
2 years ago
Pagely.php
2 years ago
PagelyCachePurge.php
4 years ago
Pantheon.php
2 years ago
Pressable.php
2 years ago
Raidboxes.php
2 years ago
RocketNet.php
3 years ago
Savvii.php
3 years ago
SiteGround.php
2 years ago
SpinupWp.php
2 years ago
Vimexx.php
3 years ago
WPEngine.php
2 years ago
WPX.php
3 years ago
WPmudev.php
2 years ago
Raidboxes.php
57 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Raidboxes Class |
| 4 | * |
| 5 | * @package nitropack |
| 6 | */ |
| 7 | |
| 8 | namespace NitroPack\Integration\Hosting; |
| 9 | |
| 10 | use \NitroPack\SDK\Filesystem; |
| 11 | |
| 12 | /** |
| 13 | * Raidboxes Class |
| 14 | */ |
| 15 | class Raidboxes extends Hosting { |
| 16 | const STAGE = "very_early"; |
| 17 | |
| 18 | private $nginx_cache_path = ABSPATH . 'wp-content/nginx_cache'; |
| 19 | private $wordpress_gt_cache_path = ABSPATH . 'wp-content/gt-cache'; |
| 20 | |
| 21 | /** |
| 22 | * Detect if Raidboxes is active |
| 23 | * |
| 24 | * @return bool |
| 25 | */ |
| 26 | public static function detect() { |
| 27 | return substr(gethostname(), 0, 4) == "box-" && Filesystem::fileExists(nitropack_trailingslashit(ABSPATH) . 'rb-plugins'); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Initialize Raidboxes |
| 32 | * |
| 33 | * @param $stage |
| 34 | * @return void |
| 35 | */ |
| 36 | public function init($stage) { |
| 37 | if (self::detect()) { |
| 38 | add_action('nitropack_execute_purge_url', [$this, 'purgeCache']); |
| 39 | add_action('nitropack_execute_purge_all', [$this, 'purgeCache']); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | private function purgeCacheDirectory($directory) { |
| 44 | try { |
| 45 | Filesystem::deleteDir($directory); |
| 46 | } catch (\Exception $e) { |
| 47 | // TODO: Log this |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | public function purgeCache() { |
| 53 | $this->purgeCacheDirectory($this->nginx_cache_path); |
| 54 | $this->purgeCacheDirectory($this->wordpress_gt_cache_path); |
| 55 | } |
| 56 | } |
| 57 |