| 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 |
]; |
| 37 |
add_option( ABLOCKS_ADDONS_SETTINGS_NAME, wp_json_encode( $addons_default_settings ) ); |
| 38 |
} |
| 39 |
if ( ! get_option( 'ablocks_first_install_time' ) ) { |
| 40 |
add_option( 'ablocks_first_install_time', Helper::get_time(), '', false ); |
| 41 |
} |
| 42 |
add_option( 'ablocks_need_activation_redirect', true ); |
| 43 |
} |
| 44 |
public function create_pages() { |
| 45 |
\ABlocks\CreatePage\ForgetPasswordPage::init(); |
| 46 |
\ABlocks\CreatePage\LoginPage::init(); |
| 47 |
\ABlocks\CreatePage\RegisterPage::init(); |
| 48 |
} |
| 49 |
} |
| 50 |
|