| @@ -1,117 +1,109 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Boxzilla; |
| 4 | 4 | |
| 5 | -class Plugin | |
| 6 | -{ | |
| 7 | - /** | |
| 8 | - * @var string The current version of the plugin | |
| 9 | - */ | |
| 10 | - protected $version = '1.0'; | |
| 5 | +class Plugin { | |
| 11 | 6 | |
| 12 | - /** | |
| 13 | - * @var string | |
| 14 | - */ | |
| 15 | - protected $file = ''; | |
| 7 | + /** | |
| 8 | + * @var string The current version of the plugin | |
| 9 | + */ | |
| 10 | + protected $version = '1.0'; | |
| 16 | 11 | |
| 17 | - /** | |
| 18 | - * @var string | |
| 19 | - */ | |
| 20 | - protected $dir = ''; | |
| 12 | + /** | |
| 13 | + * @var string | |
| 14 | + */ | |
| 15 | + protected $file = ''; | |
| 21 | 16 | |
| 22 | - /** | |
| 23 | - * @var string | |
| 24 | - */ | |
| 25 | - protected $name = ''; | |
| 17 | + /** | |
| 18 | + * @var string | |
| 19 | + */ | |
| 20 | + protected $dir = ''; | |
| 26 | 21 | |
| 27 | - /** | |
| 28 | - * @var string | |
| 29 | - */ | |
| 30 | - protected $slug = ''; | |
| 22 | + /** | |
| 23 | + * @var string | |
| 24 | + */ | |
| 25 | + protected $name = ''; | |
| 31 | 26 | |
| 32 | - /** | |
| 33 | - * @var string | |
| 34 | - */ | |
| 35 | - protected $id = ''; | |
| 27 | + /** | |
| 28 | + * @var string | |
| 29 | + */ | |
| 30 | + protected $slug = ''; | |
| 36 | 31 | |
| 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); | |
| 32 | + /** | |
| 33 | + * @var int | |
| 34 | + */ | |
| 35 | + protected $id = 0; | |
| 54 | 36 | |
| 55 | - if (empty($dir)) { | |
| 56 | - $this->dir = dirname($file); | |
| 57 | - } | |
| 58 | - } | |
| 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 ); | |
| 59 | 53 | |
| 60 | - /** | |
| 61 | - * @return string | |
| 62 | - */ | |
| 63 | - public function id() | |
| 64 | - { | |
| 65 | - return $this->id; | |
| 66 | - } | |
| 54 | + if( empty( $dir ) ) { | |
| 55 | + $this->dir = dirname( $file ); | |
| 56 | + } | |
| 57 | + } | |
| 67 | 58 | |
| 68 | - /** | |
| 69 | - * @return string | |
| 70 | - */ | |
| 71 | - public function slug() | |
| 72 | - { | |
| 73 | - return $this->slug; | |
| 74 | - } | |
| 59 | + /** | |
| 60 | + * @return int | |
| 61 | + */ | |
| 62 | + public function id() { | |
| 63 | + return $this->id; | |
| 64 | + } | |
| 75 | 65 | |
| 76 | - /** | |
| 77 | - * @return string | |
| 78 | - */ | |
| 79 | - public function name() | |
| 80 | - { | |
| 81 | - return $this->name; | |
| 82 | - } | |
| 66 | + /** | |
| 67 | + * @return string | |
| 68 | + */ | |
| 69 | + public function slug() { | |
| 70 | + return $this->slug; | |
| 71 | + } | |
| 83 | 72 | |
| 84 | - /** | |
| 85 | - * @return string | |
| 86 | - */ | |
| 87 | - public function version() | |
| 88 | - { | |
| 89 | - return $this->version; | |
| 90 | - } | |
| 73 | + /** | |
| 74 | + * @return string | |
| 75 | + */ | |
| 76 | + public function name() { | |
| 77 | + return $this->name; | |
| 78 | + } | |
| 91 | 79 | |
| 92 | - /** | |
| 93 | - * @return string | |
| 94 | - */ | |
| 95 | - public function file() | |
| 96 | - { | |
| 97 | - return $this->file; | |
| 98 | - } | |
| 80 | + /** | |
| 81 | + * @return string | |
| 82 | + */ | |
| 83 | + public function version() { | |
| 84 | + return $this->version; | |
| 85 | + } | |
| 99 | 86 | |
| 100 | - /** | |
| 101 | - * @return string | |
| 102 | - */ | |
| 103 | - public function dir() | |
| 104 | - { | |
| 105 | - return $this->dir; | |
| 106 | - } | |
| 87 | + /** | |
| 88 | + * @return string | |
| 89 | + */ | |
| 90 | + public function file() { | |
| 91 | + return $this->file; | |
| 92 | + } | |
| 107 | 93 | |
| 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 | -} | |
| 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 | +} | |