PluginProbe
User Access Manager / 2.3.10
User Access Manager v2.3.10
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
user-access-manager / src / Config / WordpressConfig.php

WordpressConfig.php in User Access Manager 2.3.10, at src/Config/WordpressConfig.php

79 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 declare(strict_types=1);
4
5 namespace UserAccessManager\Config;
6
7 use UserAccessManager\Wrapper\Wordpress;
8
9 class WordpressConfig
10 {
11 private ?bool $isPermalinksActive = null;
12 private ?array $mimeTypes = null;
13
14 public function __construct(
15 private Wordpress $wordpress,
16 private string $baseFile
17 ) {
18 }
19
20 public function atAdminPanel(): bool
21 {
22 return $this->wordpress->isAdmin();
23 }
24
25 public function isPermalinksActive(): ?bool
26 {
27 if ($this->isPermalinksActive === null) {
28 $permalinkStructure = $this->wordpress->getOption('permalink_structure');
29 $this->isPermalinksActive = (empty($permalinkStructure) === false);
30 }
31
32 return $this->isPermalinksActive;
33 }
34
35 public function getUploadDirectory(): ?string
36 {
37 $wordpressUploadDir = $this->wordpress->getUploadDir();
38
39 if (empty($wordpressUploadDir['error'])) {
40 return $wordpressUploadDir['basedir'] . DIRECTORY_SEPARATOR;
41 }
42
43 return null;
44 }
45
46 public function getMimeTypes(): ?array
47 {
48 if ($this->mimeTypes === null) {
49 $mimeTypes = $this->wordpress->getAllowedMimeTypes();
50 $fullMimeTypes = [];
51
52 foreach ($mimeTypes as $extensions => $mineType) {
53 $extensions = explode('|', $extensions);
54
55 foreach ($extensions as $extension) {
56 $fullMimeTypes[$extension] = $mineType;
57 }
58 }
59
60 $this->mimeTypes = $fullMimeTypes;
61 }
62
63 return $this->mimeTypes;
64 }
65
66 public function getUrlPath(): string
67 {
68 return $this->wordpress->pluginsUrl('', $this->baseFile) . '/';
69 }
70
71 public function getRealPath(): string
72 {
73 $dirName = dirname($this->baseFile);
74
75 return $this->wordpress->getPluginDir() . DIRECTORY_SEPARATOR
76 . $this->wordpress->pluginBasename($dirName) . DIRECTORY_SEPARATOR;
77 }
78 }
79