PluginProbe
User Access Manager / 2.2.3
User Access Manager v2.2.3
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Config/WordpressConfig.php +70 -6 trunk2.2.3 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * WordpressConfig.php
4 + *
5 + * The WordpressConfig class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Config;
@@ -5,24 +18,59 @@
5 18 namespace UserAccessManager\Config;
6 19
7 20 use UserAccessManager\Wrapper\Wordpress;
8 21
22 +/**
23 + * Class WordpressConfig
24 + *
25 + * @package UserAccessManager\Config
26 + */
9 27 class WordpressConfig
10 28 {
11 - private ?bool $isPermalinksActive = null;
12 - private ?array $mimeTypes = null;
29 + /**
30 + * @var Wordpress
31 + */
32 + private $wordpress;
13 33
14 - public function __construct(
15 - private Wordpress $wordpress,
16 - private string $baseFile
17 - ) {
34 + /**
35 + * @var string
36 + */
37 + private $baseFile;
38 +
39 + /**
40 + * @var null|bool
41 + */
42 + private $isPermalinksActive = null;
43 +
44 + /**
45 + * @var null|array
46 + */
47 + private $mimeTypes = null;
48 +
49 + /**
50 + * WordpressClass constructor.
51 + * @param Wordpress $wordpress
52 + * @param string $baseFile
53 + */
54 + public function __construct(Wordpress $wordpress, string $baseFile)
55 + {
56 + $this->wordpress = $wordpress;
57 + $this->baseFile = $baseFile;
18 58 }
19 59
60 + /**
61 + * Returns true if a user is at the admin panel.
62 + * @return bool
63 + */
20 64 public function atAdminPanel(): bool
21 65 {
22 66 return $this->wordpress->isAdmin();
23 67 }
24 68
69 + /**
70 + * Returns true if permalinks are active otherwise false.
71 + * @return bool
72 + */
25 73 public function isPermalinksActive(): ?bool
26 74 {
27 75 if ($this->isPermalinksActive === null) {
28 76 $permalinkStructure = $this->wordpress->getOption('permalink_structure');
@@ -31,8 +79,12 @@
31 79
32 80 return $this->isPermalinksActive;
33 81 }
34 82
83 + /**
84 + * Returns the upload directory.
85 + * @return null|string
86 + */
35 87 public function getUploadDirectory(): ?string
36 88 {
37 89 $wordpressUploadDir = $this->wordpress->getUploadDir();
38 90
@@ -42,8 +94,12 @@
42 94
43 95 return null;
44 96 }
45 97
98 + /**
99 + * Returns the full supported mine types.
100 + * @return array
101 + */
46 102 public function getMimeTypes(): ?array
47 103 {
48 104 if ($this->mimeTypes === null) {
49 105 $mimeTypes = $this->wordpress->getAllowedMimeTypes();
@@ -62,13 +118,21 @@
62 118
63 119 return $this->mimeTypes;
64 120 }
65 121
122 + /**
123 + * Returns the module url path.
124 + * @return string
125 + */
66 126 public function getUrlPath(): string
67 127 {
68 128 return $this->wordpress->pluginsUrl('', $this->baseFile) . '/';
69 129 }
70 130
131 + /**
132 + * Returns the module real path.
133 + * @return string
134 + */
71 135 public function getRealPath(): string
72 136 {
73 137 $dirName = dirname($this->baseFile);
74 138