| @@ -1,0 +1,50 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks; | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 8 | +use ABlocks\Admin\Settings; | |
| 9 | + | |
| 10 | +class Installer { | |
| 11 | + | |
| 12 | + public $ablocks_version; | |
| 13 | + public static function init() { | |
| 14 | + $self = new self(); | |
| 15 | + $self->ablocks_version = get_option( 'ablocks_version' ); | |
| 16 | + Database::create_initial_custom_table(); | |
| 17 | + $self->save_main_settings(); | |
| 18 | + // Save option table data | |
| 19 | + $self->save_option(); | |
| 20 | + // create pages | |
| 21 | + if ( ! $self->ablocks_version ) { | |
| 22 | + $self->create_pages(); | |
| 23 | + } | |
| 24 | + } | |
| 25 | + public function save_main_settings() { | |
| 26 | + Settings::save_settings(); | |
| 27 | + } | |
| 28 | + public function save_option() { | |
| 29 | + if ( ! $this->ablocks_version ) { | |
| 30 | + add_option( 'ablocks_version', ABLOCKS_VERSION ); | |
| 31 | + add_option( 'ablocks_fonts', '{}' ); | |
| 32 | + // Save Default activated addon | |
| 33 | + $addons_default_settings = [ | |
| 34 | + 'theme-builder' => false, | |
| 35 | + 'cookie-consent' => false, | |
| 36 | + 'link-guard' => false, | |
| 37 | + ]; | |
| 38 | + add_option( ABLOCKS_ADDONS_SETTINGS_NAME, wp_json_encode( $addons_default_settings ) ); | |
| 39 | + } | |
| 40 | + if ( ! get_option( 'ablocks_first_install_time' ) ) { | |
| 41 | + add_option( 'ablocks_first_install_time', Helper::get_time(), '', false ); | |
| 42 | + } | |
| 43 | + add_option( 'ablocks_need_activation_redirect', true ); | |
| 44 | + } | |
| 45 | + public function create_pages() { | |
| 46 | + \ABlocks\CreatePage\ForgetPasswordPage::init(); | |
| 47 | + \ABlocks\CreatePage\LoginPage::init(); | |
| 48 | + \ABlocks\CreatePage\RegisterPage::init(); | |
| 49 | + } | |
| 50 | +} | |