| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* CoreFramework |
| 5 |
* |
| 6 |
* @package CoreFramework |
| 7 |
* @author Core Framework <hello@coreframework.com> |
| 8 |
* @copyright 2023 Core Framework |
| 9 |
* @license MIT |
| 10 |
* @link https://coreframework.com |
| 11 |
*/ |
| 12 |
|
| 13 |
declare(strict_types=1); |
| 14 |
|
| 15 |
namespace CoreFramework\Config; |
| 16 |
|
| 17 |
use CoreFramework\Common\Traits\Singleton; |
| 18 |
|
| 19 |
/** |
| 20 |
* Plugin data which are used through the plugin, most of them are defined |
| 21 |
* by the root file meta data. The data is being inserted in each class |
| 22 |
* that extends the Base abstract class |
| 23 |
* |
| 24 |
* @see Base |
| 25 |
* @package CoreFramework\Config |
| 26 |
* @since 0.0.0 |
| 27 |
*/ |
| 28 |
final class Plugin { |
| 29 |
|
| 30 |
/** |
| 31 |
* Singleton trait |
| 32 |
*/ |
| 33 |
use Singleton; |
| 34 |
|
| 35 |
/** |
| 36 |
* Get the plugin meta data from the root file and include own data |
| 37 |
* |
| 38 |
* @since 0.0.0 |
| 39 |
*/ |
| 40 |
public function data(): array { |
| 41 |
$plugin_data = \apply_filters( |
| 42 |
'core_framework_plugin_data', |
| 43 |
array( |
| 44 |
'development' => CoreFramework()->isDev(), |
| 45 |
) |
| 46 |
); |
| 47 |
return array_merge( |
| 48 |
\apply_filters( |
| 49 |
'core_framework_plugin_meta_data', |
| 50 |
\get_file_data( |
| 51 |
CORE_FRAMEWORK_ABSOLUTE, |
| 52 |
array( |
| 53 |
'name' => 'Plugin Name', |
| 54 |
'uri' => 'Plugin URI', |
| 55 |
'description' => 'Description', |
| 56 |
'version' => 'Version', |
| 57 |
'author' => 'Author', |
| 58 |
'author-uri' => 'Author URI', |
| 59 |
'text-domain' => 'Text Domain', |
| 60 |
'domain-path' => 'Domain Path', |
| 61 |
'required-php' => 'Requires PHP', |
| 62 |
'required-wp' => 'Requires WP', |
| 63 |
'namespace' => 'Namespace', |
| 64 |
), |
| 65 |
'plugin' |
| 66 |
) |
| 67 |
), |
| 68 |
$plugin_data |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Get the plugin settings |
| 74 |
* |
| 75 |
* @since 0.0.0 |
| 76 |
*/ |
| 77 |
public function settings(): string { |
| 78 |
return $this->data()['settings']; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Get the plugin version number |
| 83 |
* |
| 84 |
* @since 0.0.0 |
| 85 |
*/ |
| 86 |
public function version(): string { |
| 87 |
return $this->data()['version']; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Get the required minimum PHP version |
| 92 |
* |
| 93 |
* @since 0.0.0 |
| 94 |
*/ |
| 95 |
public function requiredPHP(): string { |
| 96 |
return $this->data()['required-php']; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Get the required minimum WP version |
| 101 |
* |
| 102 |
* @since 0.0.0 |
| 103 |
*/ |
| 104 |
public function requiredWP(): string { |
| 105 |
return $this->data()['required-wp']; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* Get the plugin name |
| 110 |
* |
| 111 |
* @since 0.0.0 |
| 112 |
*/ |
| 113 |
public function name(): string { |
| 114 |
return $this->data()['name']; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Get the plugin url |
| 119 |
* |
| 120 |
* @since 0.0.0 |
| 121 |
*/ |
| 122 |
public function uri(): string { |
| 123 |
return $this->data()['uri']; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Get the plugin description |
| 128 |
* |
| 129 |
* @since 0.0.0 |
| 130 |
*/ |
| 131 |
public function description(): string { |
| 132 |
return $this->data()['description']; |
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Get the plugin author |
| 137 |
* |
| 138 |
* @since 0.0.0 |
| 139 |
*/ |
| 140 |
public function author(): string { |
| 141 |
return $this->data()['author']; |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* Get the plugin author uri |
| 146 |
* |
| 147 |
* @since 0.0.0 |
| 148 |
*/ |
| 149 |
public function authorUri(): string { |
| 150 |
return $this->data()['author-uri']; |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Get the plugin text domain |
| 155 |
* |
| 156 |
* @since 0.0.0 |
| 157 |
*/ |
| 158 |
public function textDomain(): string { |
| 159 |
return $this->data()['text-domain']; |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* Get the plugin domain path |
| 164 |
* |
| 165 |
* @since 0.0.0 |
| 166 |
*/ |
| 167 |
public function domainPath(): string { |
| 168 |
return $this->data()['domain-path']; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Get the plugin namespace |
| 173 |
* |
| 174 |
* @since 0.0.0 |
| 175 |
*/ |
| 176 |
public function namespace(): string { |
| 177 |
return $this->data()['namespace']; |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Get the plugin namespace |
| 182 |
* |
| 183 |
* @since 0.0.0 |
| 184 |
*/ |
| 185 |
public function isDev(): bool { |
| 186 |
return $this->data()['development']; |
| 187 |
} |
| 188 |
} |
| 189 |
|