<?php

/**
 * Plugin Name: WP Immo Sync
 * Text Domain: wpis
 * Domain Path: /languages
 * Plugin URI: https://wp.immosync.com
 * Description: Import and synchronize your estates in Wordpress with your realestate software (Whise, Omnicasa, Sweepbright, Activimmo)
 * Version: 1.9.14
 * Author: Jeremy Jamar
 * Author URI: https://www.immosync.com/
 * License: GPL2
 */

namespace WPIS;

require_once 'core/EstateProperties.php';
require_once 'core/AdminAssetsManager.php';
require_once 'core/ClientAssetsManager.php';
require_once 'core/PostTypesManager.php';
require_once 'core/ShortcodesManager.php';
require_once 'utilities/ThemeTemplateResolver.php';
require_once 'core/FormManager.php';
require_once 'core/DatabaseManager.php';
require_once 'core/WpCliManager.php';

require_once 'utilities/SettingsManager.php';
require_once 'utilities/Logger.php';
require_once 'utilities/Updater.php';
require_once 'utilities/Tools.php';
require_once 'api/AdminApi.php';
require_once 'api/PublicApi.php';
require_once 'api/ImmosyncClient.php';
require_once 'core/Filters/NumberFilter.php';
require_once 'core/Filters/DecimalFilter.php';
require_once 'core/Filters/PriceFilter.php';
require_once 'core/Filters/CapitalizeFilter.php';
require_once 'core/Filters/UppercaseFilter.php';
require_once 'core/Filters/EpcImageFilter.php';
require_once 'core/Filters/YesNoFilter.php';

require_once ABSPATH . 'wp-admin/includes/upgrade.php';

class WPIS
{
  public const API_URL = 'https://api.immosync.com';
  public const EMAIL_CONTACT_FAILURE = 'wp-contact-sync-failures@immosync.com';

  public const WP_TABLE_CONNEXION = 'wpis_connexion';
  public const WP_TABLE_SETTINGS = 'wpis_settings';
  public const WP_TABLE_CONTACTS = 'wpis_contacts';

  public function __construct()
  {

    register_activation_hook(__FILE__, [$this, 'wpis_install']);
    register_deactivation_hook(__FILE__, [$this, 'wpis_uninstall']);

    add_action('plugins_loaded', [$this, 'wpis_init']);
    add_action('init', function () {
      load_plugin_textdomain('wpis', false, basename(dirname(__FILE__)) . '/languages');
    });
  }

  public function wpis_install()
  {
    DatabaseManager::install();
    SettingsManager::init();
  }

  public function wpis_uninstall()
  {
    DatabaseManager::uninstall();
  }

  public function wpis_init()
  {
    AdminAssetsManager::init();
    ClientAssetsManager::init();
    PostTypesManager::init();
    ShortcodesManager::init();
    FormManager::init();
    #WpCliManager::init();
    ApiAdmin::init();
    ApiPublic::init();
  }
}

new WPIS();
