| Total Complexity | 12 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class AddonInfo { |
||
| 16 | protected $name; |
||
| 17 | protected $code; |
||
| 18 | protected $version; |
||
| 19 | protected $author = 'Sudar Muthu'; |
||
| 20 | protected $root_file; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Construct AddonInfo from an array. |
||
| 24 | * |
||
| 25 | * @param array $details Details about the add-on. |
||
| 26 | */ |
||
| 27 | public function __construct( $details = array() ) { |
||
| 28 | if ( ! is_array( $details ) ) { |
||
|
|
|||
| 29 | return; |
||
| 30 | } |
||
| 31 | |||
| 32 | $keys = array( |
||
| 33 | 'name', |
||
| 34 | 'code', |
||
| 35 | 'version', |
||
| 36 | 'author', |
||
| 37 | 'root_file', |
||
| 38 | ); |
||
| 39 | |||
| 40 | foreach ( $keys as $key ) { |
||
| 41 | if ( array_key_exists( $key, $details ) ) { |
||
| 42 | $this->{$key} = $details[ $key ]; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public function get_name() { |
||
| 48 | return $this->name; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function get_code() { |
||
| 52 | return $this->code; |
||
| 53 | } |
||
| 54 | |||
| 55 | public function get_version() { |
||
| 57 | } |
||
| 58 | |||
| 59 | public function get_author() { |
||
| 61 | } |
||
| 62 | |||
| 63 | public function get_root_file() { |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Return add-on slug. |
||
| 69 | * |
||
| 70 | * Add-on slug is the name of the root file without file extension. |
||
| 71 | * |
||
| 72 | * @since 6.0.1 |
||
| 73 | * |
||
| 74 | * @return string Add-on slug. |
||
| 75 | */ |
||
| 76 | public function get_addon_slug() { |
||
| 77 | return basename( $this->root_file, '.php' ); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function get_addon_directory() { |
||
| 81 | return plugin_dir_path( $this->root_file ); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function get_addon_directory_url() { |
||
| 86 | } |
||
| 87 | } |
||
| 88 |