1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Addon; |
4
|
|
|
|
5
|
|
|
use BD_License_Handler; |
6
|
|
|
use BulkWP\BulkDelete\Core\BulkDelete; |
7
|
|
|
|
8
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Encapsulates the logic for a add-on. |
12
|
|
|
* |
13
|
|
|
* @since 6.0.0 |
14
|
|
|
*/ |
15
|
|
|
abstract class BaseAddon { |
16
|
|
|
/** |
17
|
|
|
* Details of the Add-on. |
18
|
|
|
* |
19
|
|
|
* @var \BulkWP\BulkDelete\Core\Addon\AddonInfo |
20
|
|
|
*/ |
21
|
|
|
protected $addon_info; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Handler for license. |
25
|
|
|
* |
26
|
|
|
* @var \BD_License_Handler |
27
|
|
|
*/ |
28
|
|
|
protected $license_handler; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Initialize and setup variables. |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
abstract protected function initialize(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Register the add-on. |
39
|
|
|
* |
40
|
|
|
* This method will be called in the `bd_loaded` hook. |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
abstract public function register(); |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Create a new instance of the add-on. |
48
|
|
|
* |
49
|
|
|
* @param \BulkWP\BulkDelete\Core\Addon\AddonInfo $addon_info Add-on Details. |
50
|
|
|
*/ |
51
|
|
|
public function __construct( $addon_info ) { |
52
|
|
|
$this->addon_info = $addon_info; |
53
|
|
|
|
54
|
|
|
$this->initialize(); |
55
|
|
|
$this->setup_license_handler(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get details about the add-on. |
60
|
|
|
* |
61
|
|
|
* @return \BulkWP\BulkDelete\Core\Addon\AddonInfo Add-on Info. |
62
|
|
|
*/ |
63
|
|
|
public function get_info() { |
64
|
|
|
return $this->addon_info; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Get reference to the main Bulk Delete object. |
69
|
|
|
* |
70
|
|
|
* @return \BulkWP\BulkDelete\Core\BulkDelete BulkDelete object. |
71
|
|
|
*/ |
72
|
|
|
public function get_bd() { |
73
|
|
|
return BulkDelete::get_instance(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Setup License Handler. |
78
|
|
|
* |
79
|
|
|
* TODO: Need this to be refactored. |
80
|
|
|
*/ |
81
|
|
|
protected function setup_license_handler() { |
82
|
|
|
$this->license_handler = new BD_License_Handler( |
83
|
|
|
$this->addon_info->get_name(), |
84
|
|
|
$this->addon_info->get_code(), |
85
|
|
|
$this->addon_info->get_version(), |
86
|
|
|
$this->addon_info->get_root_file(), |
87
|
|
|
$this->addon_info->get_author() |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|