PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.5.2
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.5.2
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / webp / class-wpo-htaccess-capabilities.php

class-wpo-htaccess-capabilities.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.5.2, at webp/class-wpo-htaccess-capabilities.php

90 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) 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 htaccess capabilities as properties
14 *
15 * @var HtaccessCapabilityTester
16 */
17 public $hct;
18
19 /**
20 * @var bool
21 */
22 public $htaccess_enabled;
23
24 /**
25 * @var bool
26 */
27 public $mod_headers;
28
29 /**
30 * @var bool
31 */
32 public $mod_mime;
33
34 /**
35 * @var bool
36 */
37 public $mod_rewrite;
38
39 /**
40 * Constructor
41 */
42 public function __construct() {
43 $uploads = wp_upload_dir();
44 $this->hct = new HtaccessCapabilityTester($uploads['basedir'] . '/wpo', $uploads['baseurl'] . '/wpo');
45 $this->htaccess_enabled = (bool) $this->hct->htaccessEnabled();
46 $this->mod_headers = $this->get_mod_header_status();
47 $this->mod_mime = $this->get_mod_mime_status();
48 $this->mod_rewrite = $this->get_mod_rewrite_status();
49 }
50
51 /**
52 * Gets singleton instance
53 *
54 * @return self
55 */
56 public static function get_instance() {
57 if (null === self::$_instance) {
58 self::$_instance = new WPO_Htaccess_Capabilities();
59 }
60 return self::$_instance;
61 }
62
63 /**
64 * Gets `mod_headers` status by checking if it is loaded and working
65 *
66 * @return bool
67 */
68 public function get_mod_header_status() {
69 return (true === $this->hct->moduleLoaded('headers') && true === $this->hct->headerSetWorks());
70 }
71
72 /**
73 * Gets `mod_mime` status by checking if it is loaded and working
74 *
75 * @return bool
76 */
77 public function get_mod_mime_status() {
78 return (true === $this->hct->moduleLoaded('mime') && true === $this->hct->addTypeWorks());
79 }
80
81 /**
82 * Gets `mod_rewrite` status by checking if it is loaded and working
83 *
84 * @return bool
85 */
86 public function get_mod_rewrite_status() {
87 return (true === $this->hct->moduleLoaded('rewrite') && true == $this->hct->rewriteWorks());
88 }
89 }
90