| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('WPO_PLUGIN_MAIN_PATH')) die('No direct access allowed'); |
| 4 |
|
| 5 |
require_once(WPO_PLUGIN_MAIN_PATH . 'vendor/autoload.php'); |
| 6 |
use HtaccessCapabilityTester\HtaccessCapabilityTester; |
| 7 |
|
| 8 |
class WPO_Htaccess_Capabilities { |
| 9 |
|
| 10 |
private static $_instance = null; |
| 11 |
|
| 12 |
/** |
| 13 |
* Tests and sets up server's htacess capabilities as properties |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
$uploads = wp_upload_dir(); |
| 17 |
$this->hct = new HtaccessCapabilityTester($uploads['basedir'] . '/wpo/', $uploads['baseurl'] . '/wpo/'); |
| 18 |
$this->htaccess_enabled = $this->hct->htaccessEnabled(); |
| 19 |
$this->mod_headers = $this->get_mod_header_status(); |
| 20 |
$this->mod_mime = $this->get_mod_mime_status(); |
| 21 |
$this->mod_rewrite = $this->get_mod_rewrite_status(); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Gets singleton instance |
| 26 |
* |
| 27 |
* @return object |
| 28 |
*/ |
| 29 |
public static function get_instance() { |
| 30 |
if (null === self::$_instance) { |
| 31 |
self::$_instance = new WPO_Htaccess_Capabilities(); |
| 32 |
} |
| 33 |
return self::$_instance; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Gets `mod_headers` status by checking if it is loaded and working |
| 38 |
* |
| 39 |
* @return bool |
| 40 |
*/ |
| 41 |
public function get_mod_header_status() { |
| 42 |
return (true === $this->hct->moduleLoaded('headers') && true === $this->hct->headerSetWorks()); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Gets `mod_mime` status by checking if it is loaded and working |
| 47 |
* |
| 48 |
* @return bool |
| 49 |
*/ |
| 50 |
public function get_mod_mime_status() { |
| 51 |
return (true === $this->hct->moduleLoaded('mime') && true === $this->hct->addTypeWorks()); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Gets `mod_rewrite` status by checking if it is loaded and working |
| 56 |
* |
| 57 |
* @return bool |
| 58 |
*/ |
| 59 |
public function get_mod_rewrite_status() { |
| 60 |
return (true === $this->hct->moduleLoaded('rewrite') && true == $this->hct->rewriteWorks()); |
| 61 |
} |
| 62 |
} |
| 63 |
|