| @@ -1,29 +1,77 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | -declare(strict_types=1); | |
| 4 | - | |
| 2 | +/** | |
| 3 | + * WordpressConfig.php | |
| 4 | + * | |
| 5 | + * The WordpressConfig class file. | |
| 6 | + * | |
| 7 | + * PHP versions 5 | |
| 8 | + * | |
| 9 | + * @author Alexander Schneider <[email protected]> | |
| 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 | + */ | |
| 5 | 15 | namespace UserAccessManager\Config; |
| 6 | 16 | |
| 7 | 17 | use UserAccessManager\Wrapper\Wordpress; |
| 8 | 18 | |
| 19 | +/** | |
| 20 | + * Class WordpressConfig | |
| 21 | + * | |
| 22 | + * @package UserAccessManager\Config | |
| 23 | + */ | |
| 9 | 24 | class WordpressConfig |
| 10 | 25 | { |
| 11 | - private ?bool $isPermalinksActive = null; | |
| 12 | - private ?array $mimeTypes = null; | |
| 26 | + /** | |
| 27 | + * @var Wordpress | |
| 28 | + */ | |
| 29 | + private $wordpress; | |
| 13 | 30 | |
| 14 | - public function __construct( | |
| 15 | - private Wordpress $wordpress, | |
| 16 | - private string $baseFile | |
| 17 | - ) { | |
| 31 | + /** | |
| 32 | + * @var string | |
| 33 | + */ | |
| 34 | + private $baseFile; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * @var null|bool | |
| 38 | + */ | |
| 39 | + private $isPermalinksActive = null; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * @var null|array | |
| 43 | + */ | |
| 44 | + private $mimeTypes = null; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * WordpressClass constructor. | |
| 48 | + * | |
| 49 | + * @param Wordpress $wordpress | |
| 50 | + * @param string $baseFile | |
| 51 | + */ | |
| 52 | + public function __construct(Wordpress $wordpress, $baseFile) | |
| 53 | + { | |
| 54 | + $this->wordpress = $wordpress; | |
| 55 | + $this->baseFile = $baseFile; | |
| 18 | 56 | } |
| 19 | 57 | |
| 20 | - public function atAdminPanel(): bool | |
| 58 | + /** | |
| 59 | + * Returns true if a user is at the admin panel. | |
| 60 | + * | |
| 61 | + * @return bool | |
| 62 | + */ | |
| 63 | + public function atAdminPanel() | |
| 21 | 64 | { |
| 22 | 65 | return $this->wordpress->isAdmin(); |
| 23 | 66 | } |
| 24 | 67 | |
| 25 | - public function isPermalinksActive(): ?bool | |
| 68 | + /** | |
| 69 | + * Returns true if permalinks are active otherwise false. | |
| 70 | + * | |
| 71 | + * @return bool | |
| 72 | + */ | |
| 73 | + public function isPermalinksActive() | |
| 26 | 74 | { |
| 27 | 75 | if ($this->isPermalinksActive === null) { |
| 28 | 76 | $permalinkStructure = $this->wordpress->getOption('permalink_structure'); |
| 29 | 77 | $this->isPermalinksActive = (empty($permalinkStructure) === false); |
| @@ -31,20 +79,30 @@ | ||
| 31 | 79 | |
| 32 | 80 | return $this->isPermalinksActive; |
| 33 | 81 | } |
| 34 | 82 | |
| 35 | - public function getUploadDirectory(): ?string | |
| 83 | + /** | |
| 84 | + * Returns the upload directory. | |
| 85 | + * | |
| 86 | + * @return null|string | |
| 87 | + */ | |
| 88 | + public function getUploadDirectory() | |
| 36 | 89 | { |
| 37 | 90 | $wordpressUploadDir = $this->wordpress->getUploadDir(); |
| 38 | 91 | |
| 39 | 92 | if (empty($wordpressUploadDir['error'])) { |
| 40 | - return $wordpressUploadDir['basedir'] . DIRECTORY_SEPARATOR; | |
| 93 | + return $wordpressUploadDir['basedir'].DIRECTORY_SEPARATOR; | |
| 41 | 94 | } |
| 42 | 95 | |
| 43 | 96 | return null; |
| 44 | 97 | } |
| 45 | 98 | |
| 46 | - public function getMimeTypes(): ?array | |
| 99 | + /** | |
| 100 | + * Returns the full supported mine types. | |
| 101 | + * | |
| 102 | + * @return array | |
| 103 | + */ | |
| 104 | + public function getMimeTypes() | |
| 47 | 105 | { |
| 48 | 106 | if ($this->mimeTypes === null) { |
| 49 | 107 | $mimeTypes = $this->wordpress->getAllowedMimeTypes(); |
| 50 | 108 | $fullMimeTypes = []; |
| @@ -62,17 +120,27 @@ | ||
| 62 | 120 | |
| 63 | 121 | return $this->mimeTypes; |
| 64 | 122 | } |
| 65 | 123 | |
| 66 | - public function getUrlPath(): string | |
| 124 | + /** | |
| 125 | + * Returns the module url path. | |
| 126 | + * | |
| 127 | + * @return string | |
| 128 | + */ | |
| 129 | + public function getUrlPath() | |
| 67 | 130 | { |
| 68 | - return $this->wordpress->pluginsUrl('', $this->baseFile) . '/'; | |
| 131 | + return $this->wordpress->pluginsUrl('', $this->baseFile).'/'; | |
| 69 | 132 | } |
| 70 | 133 | |
| 71 | - public function getRealPath(): string | |
| 134 | + /** | |
| 135 | + * Returns the module real path. | |
| 136 | + * | |
| 137 | + * @return string | |
| 138 | + */ | |
| 139 | + public function getRealPath() | |
| 72 | 140 | { |
| 73 | 141 | $dirName = dirname($this->baseFile); |
| 74 | 142 | |
| 75 | - return $this->wordpress->getPluginDir() . DIRECTORY_SEPARATOR | |
| 76 | - . $this->wordpress->pluginBasename($dirName) . DIRECTORY_SEPARATOR; | |
| 143 | + return $this->wordpress->getPluginDir().DIRECTORY_SEPARATOR | |
| 144 | + .$this->wordpress->pluginBasename($dirName).DIRECTORY_SEPARATOR; | |
| 77 | 145 | } |
| 78 | 146 | } |