| 1 |
<?php |
| 2 |
namespace Ens\Core; |
| 3 |
|
| 4 |
use Ens\Assets\Enqueue; |
| 5 |
use Ens\Flow\FlowAPI; |
| 6 |
use Ens\Flow\FlowCPT; |
| 7 |
use Ens\Hook\ActionListener; |
| 8 |
use Ens\Whatsapp\MetaCloudProvider; |
| 9 |
use Ens\Whatsapp\TemplatesAPI; |
| 10 |
|
| 11 |
/** |
| 12 |
* Class SDK |
| 13 |
* |
| 14 |
* @package Ens |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
*/ |
| 18 |
class SDK { |
| 19 |
|
| 20 |
/** |
| 21 |
* @var SDK|null |
| 22 |
*/ |
| 23 |
protected static $instance = null; |
| 24 |
|
| 25 |
public $identifier; |
| 26 |
|
| 27 |
public static function get_instance() { |
| 28 |
self::$instance = new self(); |
| 29 |
|
| 30 |
return self::$instance; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Pass config data before init. |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
* |
| 38 |
* @param array $config |
| 39 |
* |
| 40 |
* @return SDK |
| 41 |
*/ |
| 42 |
public function setup( $config ) { |
| 43 |
if(isset($config['general_prefix'])){ |
| 44 |
$this->identifier = $config['general_prefix']; |
| 45 |
update_option( $this->identifier.'_ens_config', $config ); |
| 46 |
} |
| 47 |
|
| 48 |
return $this; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Initialize SDK. |
| 53 |
* |
| 54 |
* @since 1.0.0 |
| 55 |
* |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public function init() { |
| 59 |
( new FlowCPT() )->register($this->identifier); |
| 60 |
( new FlowAPI() )->init($this->identifier); |
| 61 |
( new ActionListener() )->register($this->identifier); |
| 62 |
( new Enqueue() )->init($this->identifier); |
| 63 |
// Added for adding whatsapp support |
| 64 |
( new MetaCloudProvider( $this->identifier ) )->register(); |
| 65 |
( new TemplatesAPI() )->init( $this->identifier ); |
| 66 |
} |
| 67 |
} |