| 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 int |
| 34 |
*/ |
| 35 |
protected $id = 0; |
| 36 |
|
| 37 |
/** |
| 38 |
* Constructor |
| 39 |
* |
| 40 |
* @param int $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 |
$this->id = $id; |
| 48 |
$this->name = $name; |
| 49 |
$this->version = $version; |
| 50 |
$this->file = $file; |
| 51 |
$this->dir = $dir; |
| 52 |
$this->slug = plugin_basename( $file ); |
| 53 |
|
| 54 |
if( empty( $dir ) ) { |
| 55 |
$this->dir = dirname( $file ); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* @return int |
| 61 |
*/ |
| 62 |
public function id() { |
| 63 |
return $this->id; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* @return string |
| 68 |
*/ |
| 69 |
public function slug() { |
| 70 |
return $this->slug; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* @return string |
| 75 |
*/ |
| 76 |
public function name() { |
| 77 |
return $this->name; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @return string |
| 82 |
*/ |
| 83 |
public function version() { |
| 84 |
return $this->version; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* @return string |
| 89 |
*/ |
| 90 |
public function file() { |
| 91 |
return $this->file; |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* @return string |
| 96 |
*/ |
| 97 |
public function dir() { |
| 98 |
return $this->dir; |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* @param string $path |
| 103 |
* |
| 104 |
* @return mixed |
| 105 |
*/ |
| 106 |
public function url( $path = '' ) { |
| 107 |
return plugins_url( $path, $this->file() ); |
| 108 |
} |
| 109 |
} |