Activate.php
66 lines
| 1 | <?php |
| 2 | namespace NestedPages\Activation; |
| 3 | |
| 4 | use NestedPages\Activation\Updates\Updates; |
| 5 | |
| 6 | /** |
| 7 | * Plugin Activation |
| 8 | */ |
| 9 | class Activate |
| 10 | { |
| 11 | /** |
| 12 | * Plugin Version |
| 13 | */ |
| 14 | private $version; |
| 15 | |
| 16 | /** |
| 17 | * Updates |
| 18 | * @var object |
| 19 | */ |
| 20 | private $updates; |
| 21 | |
| 22 | public function __construct() |
| 23 | { |
| 24 | $this->setVersion(); |
| 25 | $this->updates = new Updates; |
| 26 | $this->install(); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Activation Hook |
| 31 | */ |
| 32 | public function install() |
| 33 | { |
| 34 | $this->updates->run($this->version); |
| 35 | $this->saveVersion(); |
| 36 | $this->setOptions(); |
| 37 | new Dependencies; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Set the Plugin Version |
| 42 | */ |
| 43 | private function setVersion() |
| 44 | { |
| 45 | global $np_version; |
| 46 | $this->version = $np_version; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Set the Plugin Version |
| 51 | */ |
| 52 | private function saveVersion() |
| 53 | { |
| 54 | update_option('nestedpages_version', $this->version); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Set Default Options |
| 59 | */ |
| 60 | private function setOptions() |
| 61 | { |
| 62 | if ( !get_option('nestedpages_menusync') ){ |
| 63 | update_option('nestedpages_menusync', 'nosync'); |
| 64 | } |
| 65 | } |
| 66 | } |