|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Base class for all BD Addons. |
|
4
|
|
|
* |
|
5
|
|
|
* @since 5.5 |
|
6
|
|
|
* |
|
7
|
|
|
* @author Sudar |
|
8
|
|
|
* |
|
9
|
|
|
* @package BulkDelete\Addons\Base |
|
10
|
|
|
*/ |
|
11
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Base class for BD Addons. |
|
15
|
|
|
* |
|
16
|
|
|
* @abstract |
|
17
|
|
|
* |
|
18
|
|
|
* @since 5.5 |
|
19
|
|
|
*/ |
|
20
|
|
|
abstract class BD_Addon { |
|
21
|
|
|
/** |
|
22
|
|
|
* @var string Addon Name. |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $addon_name; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var string Addon Code. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $addon_code; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string Addon File. |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $addon_file; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string Addon Version. |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $addon_version; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var string Addon Author. |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $addon_author = 'Sudar Muthu'; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var Module Name. |
|
|
|
|
|
|
48
|
|
|
*/ |
|
49
|
|
|
protected $module; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var object License Handler. |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $license_handler; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Initialize and setup variables. |
|
58
|
|
|
* |
|
59
|
|
|
* @since 5.5 |
|
60
|
|
|
* @abstract |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
|
|
abstract protected function initialize(); |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Use `factory()` method to create instance of this class. |
|
68
|
|
|
* Don't create instances directly. |
|
69
|
|
|
* |
|
70
|
|
|
* @since 5.5 |
|
71
|
|
|
* @see factory() |
|
72
|
|
|
*/ |
|
73
|
|
|
public function __construct() { |
|
74
|
|
|
$this->setup(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Setup the module. |
|
79
|
|
|
* |
|
80
|
|
|
* @access protected |
|
81
|
|
|
* |
|
82
|
|
|
* @since 5.5 |
|
83
|
|
|
*/ |
|
84
|
|
|
protected function setup() { |
|
85
|
|
|
$this->initialize(); |
|
86
|
|
|
$this->setup_translation(); |
|
87
|
|
|
if ( $this->dependencies_met() ) { |
|
88
|
|
|
$this->setup_hooks(); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Check if all dependencies are met. |
|
94
|
|
|
* To check for dependencies overload this method in the child class. |
|
95
|
|
|
* |
|
96
|
|
|
* @return bool True if dependencies met, False otherwise. |
|
97
|
|
|
*/ |
|
98
|
|
|
protected function dependencies_met() { |
|
99
|
|
|
return true; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Setup translation. |
|
104
|
|
|
* |
|
105
|
|
|
* @access protected |
|
106
|
|
|
* |
|
107
|
|
|
* @since 5.5 |
|
108
|
|
|
*/ |
|
109
|
|
|
protected function setup_translation() { |
|
110
|
|
|
$bd = BULK_DELETE(); |
|
111
|
|
|
|
|
112
|
|
|
// Load translation files from Bulk Delete language folder |
|
113
|
|
|
load_plugin_textdomain( 'bulk-delete', false, $bd->translations ); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Setup license handler. |
|
118
|
|
|
* |
|
119
|
|
|
* @since 5.5 |
|
120
|
|
|
* |
|
121
|
|
|
* @param string $plugin_file Addon file name relative to plugin directory. |
|
122
|
|
|
*/ |
|
123
|
|
|
public function setup_license_handler( $plugin_file ) { |
|
124
|
|
|
$this->addon_file = $plugin_file; |
|
125
|
|
|
$this->license_handler = new BD_License_Handler( |
|
126
|
|
|
$this->addon_name, |
|
127
|
|
|
$this->addon_code, |
|
128
|
|
|
$this->addon_version, |
|
129
|
|
|
$this->addon_file, |
|
130
|
|
|
$this->addon_author |
|
131
|
|
|
); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Get addon class name. |
|
136
|
|
|
* |
|
137
|
|
|
* @since 5.5 |
|
138
|
|
|
* |
|
139
|
|
|
* @return string Addon class name |
|
140
|
|
|
*/ |
|
141
|
|
|
protected function get_addon_class_name() { |
|
142
|
|
|
return bd_get_addon_class_name( $this->addon_name ); |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths