| 1 |
<?php namespace Premmerce\Premmerce; |
| 2 |
|
| 3 |
use Premmerce\Premmerce\Admin\Admin; |
| 4 |
use Premmerce\Premmerce\Api\WizardApi; |
| 5 |
use Premmerce\Premmerce\WordpressSDK\FileManager\FileManager; |
| 6 |
use Premmerce\Premmerce\WordpressSDK\Plugin\PluginInterface; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class PremiumPlugin |
| 10 |
* |
| 11 |
* @package Premmerce\Premium |
| 12 |
*/ |
| 13 |
class PremmercePlugin implements PluginInterface{ |
| 14 |
|
| 15 |
const SLUG = 'premmerce'; |
| 16 |
|
| 17 |
const VERSION_OPTION = 'premmerce_version'; |
| 18 |
|
| 19 |
const IS_PREMIUM = true; |
| 20 |
|
| 21 |
/** |
| 22 |
* @var FileManager |
| 23 |
*/ |
| 24 |
private $fileManager; |
| 25 |
|
| 26 |
/** |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
private $version = '1.0'; |
| 30 |
|
| 31 |
|
| 32 |
/** |
| 33 |
* PluginManager constructor. |
| 34 |
* |
| 35 |
* @param $mainFile |
| 36 |
* |
| 37 |
*/ |
| 38 |
public function __construct($mainFile){ |
| 39 |
$this->fileManager = new FileManager($mainFile); |
| 40 |
|
| 41 |
add_action('init', [$this, 'loadTextDomain']); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Run plugin part |
| 46 |
*/ |
| 47 |
public function run(){ |
| 48 |
if(is_admin()){ |
| 49 |
new Admin(new Container($this->fileManager)); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Load plugin translations |
| 55 |
*/ |
| 56 |
public function loadTextDomain(){ |
| 57 |
$name = $this->fileManager->getPluginName(); |
| 58 |
load_plugin_textdomain('premmerce', false, $name . '/languages/'); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Fired when the plugin is activated |
| 63 |
*/ |
| 64 |
public function activate(){ |
| 65 |
update_option(self::VERSION_OPTION, $this->version, true); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Fired when the plugin is deactivated |
| 70 |
*/ |
| 71 |
public function deactivate(){ |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Fired during plugin uninstall |
| 76 |
*/ |
| 77 |
public static function uninstall(){ |
| 78 |
delete_option(self::VERSION_OPTION); |
| 79 |
delete_option(WizardApi::KEY_POSITIONS); |
| 80 |
delete_option(WizardApi::KEY_STATES); |
| 81 |
delete_option(WizardApi::KEY_SWITCHER_STATE); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
} |