| 1 |
<?php |
| 2 |
|
| 3 |
namespace Boxzilla; |
| 4 |
|
| 5 |
class Plugin |
| 6 |
{ |
| 7 |
/** |
| 8 |
* @var string The current version of the plugin |
| 9 |
*/ |
| 10 |
protected $version = '1.0'; |
| 11 |
|
| 12 |
/** |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
protected $file = ''; |
| 16 |
|
| 17 |
/** |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
protected $dir = ''; |
| 21 |
|
| 22 |
/** |
| 23 |
* @var string |
| 24 |
*/ |
| 25 |
protected $name = ''; |
| 26 |
|
| 27 |
/** |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
protected $slug = ''; |
| 31 |
|
| 32 |
/** |
| 33 |
* @var string |
| 34 |
*/ |
| 35 |
protected $id = ''; |
| 36 |
|
| 37 |
/** |
| 38 |
* Constructor |
| 39 |
* |
| 40 |
* @param string $id |
| 41 |
* @param string $name |
| 42 |
* @param string $version |
| 43 |
* @param string $file |
| 44 |
* @param string $dir (optional) |
| 45 |
*/ |
| 46 |
public function __construct($id, $name, $version, $file, $dir = '') |
| 47 |
{ |
| 48 |
$this->id = $id; |
| 49 |
$this->name = $name; |
| 50 |
$this->version = $version; |
| 51 |
$this->file = $file; |
| 52 |
$this->dir = $dir; |
| 53 |
$this->slug = plugin_basename($file); |
| 54 |
|
| 55 |
if (empty($dir)) { |
| 56 |
$this->dir = dirname($file); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public function id() |
| 64 |
{ |
| 65 |
return $this->id; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* @return string |
| 70 |
*/ |
| 71 |
public function slug() |
| 72 |
{ |
| 73 |
return $this->slug; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* @return string |
| 78 |
*/ |
| 79 |
public function name() |
| 80 |
{ |
| 81 |
return $this->name; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* @return string |
| 86 |
*/ |
| 87 |
public function version() |
| 88 |
{ |
| 89 |
return $this->version; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* @return string |
| 94 |
*/ |
| 95 |
public function file() |
| 96 |
{ |
| 97 |
return $this->file; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* @return string |
| 102 |
*/ |
| 103 |
public function dir() |
| 104 |
{ |
| 105 |
return $this->dir; |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* @param string $path |
| 110 |
* |
| 111 |
* @return mixed |
| 112 |
*/ |
| 113 |
public function url($path = '') |
| 114 |
{ |
| 115 |
return plugins_url($path, $this->file()); |
| 116 |
} |
| 117 |
} |
| 118 |
|