|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Addons; |
|
4
|
|
|
|
|
5
|
|
|
use ReflectionClass; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* @property string $id |
|
9
|
|
|
* @property string $slug |
|
10
|
|
|
* @property string $update_url |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class Addon |
|
13
|
|
|
{ |
|
14
|
|
|
const ID = ''; |
|
15
|
|
|
const SLUG = ''; |
|
16
|
|
|
const UPDATE_URL = ''; |
|
17
|
|
|
|
|
18
|
|
|
public $file; |
|
19
|
|
|
public $languages; |
|
20
|
|
|
public $name; |
|
21
|
|
|
public $testedTo; |
|
22
|
|
|
public $updater; |
|
23
|
|
|
public $version; |
|
24
|
|
|
|
|
25
|
|
|
public function __construct() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName()); |
|
28
|
|
|
$plugin = get_file_data($this->file, [ |
|
29
|
|
|
'languages' => 'Domain Path', |
|
30
|
|
|
'name' => 'Plugin Name', |
|
31
|
|
|
'testedTo' => 'Tested up to', |
|
32
|
|
|
'version' => 'Version', |
|
33
|
|
|
], 'plugin'); |
|
34
|
|
|
array_walk($plugin, function ($value, $key) { |
|
35
|
|
|
if (property_exists($this, $key)) { |
|
36
|
|
|
$this->$key = $value; |
|
37
|
|
|
} |
|
38
|
|
|
}); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $property |
|
43
|
|
|
* @return void|string |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __get($property) |
|
46
|
|
|
{ |
|
47
|
|
|
if (property_exists($this, $property)) { |
|
48
|
|
|
return $this->$property; |
|
49
|
|
|
} |
|
50
|
|
|
$constant = 'static::'.strtoupper($property); |
|
51
|
|
|
if (defined($constant)) { |
|
52
|
|
|
return constant($constant); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function make($class) |
|
|
|
|
|
|
57
|
|
|
{} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @return void |
|
61
|
|
|
*/ |
|
62
|
|
|
abstract public function init(); |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param string $file |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function path($file = '') |
|
69
|
|
|
{ |
|
70
|
|
|
return plugin_dir_path($this->file).ltrim(trim($file), '/'); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return void |
|
75
|
|
|
*/ |
|
76
|
|
|
public function update() |
|
77
|
|
|
{ |
|
78
|
|
|
$this->updater = new Updater(static::UPDATE_URL, $this->file, [ |
|
79
|
|
|
'license' => glsr_get_option('settings.licenses.'.static::ID), |
|
80
|
|
|
'testedTo' => $this->testedTo, |
|
81
|
|
|
]); |
|
82
|
|
|
$this->updater->init(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param string $path |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
public function url($path = '') |
|
90
|
|
|
{ |
|
91
|
|
|
return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/')); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.