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