1 | <?php |
||
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 ) { |
||
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() { |
||
143 | } |
||
144 | } |
||
145 |