| 1 |
<?php namespace EmailLog\Addon; |
| 2 |
|
| 3 |
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 4 |
|
| 5 |
/** |
| 6 |
* Base Email Log Addon. |
| 7 |
* |
| 8 |
* @since 2.0.0 |
| 9 |
*/ |
| 10 |
abstract class EmailLogAddon { |
| 11 |
|
| 12 |
protected $addon_file; |
| 13 |
protected $addon_name = ''; |
| 14 |
protected $addon_version = ''; |
| 15 |
protected $addon_author = 'Sudar Muthu'; |
| 16 |
|
| 17 |
/** |
| 18 |
* Addon Updater. |
| 19 |
* |
| 20 |
* @var \EmailLog\Addon\AddonUpdater |
| 21 |
*/ |
| 22 |
private $updater; |
| 23 |
|
| 24 |
/** |
| 25 |
* Initialize add-on data. |
| 26 |
* |
| 27 |
* @access protected |
| 28 |
* @return void |
| 29 |
*/ |
| 30 |
abstract protected function initialize(); |
| 31 |
|
| 32 |
/** |
| 33 |
* Construct a new EmailLogAddon instance. |
| 34 |
* |
| 35 |
* @param string $addon_file Addon main file. |
| 36 |
* @param \EmailLog\Addon\AddonUpdater|null $updater Addon Updater. |
| 37 |
*/ |
| 38 |
public function __construct( $addon_file, $updater = null ) { |
| 39 |
$this->addon_file = $addon_file; |
| 40 |
$this->updater = $updater; |
| 41 |
|
| 42 |
$this->initialize(); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Load the add-on and setup hooks. |
| 47 |
* |
| 48 |
* @inheritdoc |
| 49 |
*/ |
| 50 |
public function load() { |
| 51 |
if ( is_null( $this->updater ) ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
$this->updater->set_addon_data( $this->addon_name, $this->addon_version, $this->addon_author ); |
| 56 |
$this->updater->load(); |
| 57 |
} |
| 58 |
} |
| 59 |
|