<?php
use Bdp\Libs\DatabaseHandler;


require_once dirname(__FILE__) . '/pre_requires.php';
require_once dirname(__FILE__) . '/environment.php';

require_once (BDP_LV_PLUGIN_DIR . '/lib/dompdf/autoload.php');
require_once dirname(__FILE__) . '/pdfhandler.php';

require_once (BDP_LV_PLUGIN_DIR . '/includes/class-modelcommon.php');

require_once dirname(__FILE__) . '/spl.php';
require_once dirname(__FILE__) . '/update.class.php';

require_once BDP_LV_PLUGIN_DIR . 'includes/FileAccess.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/WpConfigEditor.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/DatabaseHandler.php';
require_once (BDP_LV_PLUGIN_DIR . '/includes/roles.php');



require_once (BDP_LV_PLUGIN_DIR . '/includes/filters.php');

require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/Event.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/ICal.php');

require_once (BDP_LV_PLUGIN_DIR . '/modules/seo/seo.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/calendar/calendar.php');
require_once (BDP_LV_PLUGIN_DIR . '/includes/frontend-functions.php');

require_once (BDP_LV_PLUGIN_DIR . '/modules/calendar/Views/settings-form.php');
require_once (BDP_LV_PLUGIN_DIR . '/modules/security/security.php');


$dbHandler = new DatabaseHandler();
function kompass_admin_init()
{
}

function bdp_kompass_load_plugin_textdomain() {
	load_textdomain( BDP_LV_PLUGIN_SLUG, BDP_LV_PLUGIN_DIR . '/lang/' . BDP_LV_PLUGIN_SLUG . '-' . get_locale() . '.mo' );
}


function kompass_after_setup_theme()
{
	setup_site_roles();
	register_custom_theme_directory();

}

function kompass_is_fullaged(string $birthday) : bool {
	$obj_birthday = \DateTime::createFromFormat('Y-m-d',  $birthday);
	$today = new DateTime();
	$compare = date_diff($today, $obj_birthday);
	return $compare->y >= 18;
}

function kompass_get_age(string $birthday) : int {
    $obj_birthday = \DateTime::createFromFormat('Y-m-d',  $birthday);
    $today = new DateTime();
    $compare = date_diff($today, $obj_birthday);
    return $compare->y;
}

function bdp_kompass_load_ajax_content() {
	$class = 'Bdp\\Modules\\' . $_REQUEST['module'] . '\\Controllers\\AjaxRouterController';
	if (!class_exists($class)) {
		wp_die('Invalid module call: Module=' . $_REQUEST['module']);
	}
	new $class();
	exit;
}


new BdpVersionChecker();

#add_filter( 'plugins_api', array( $class, 'info' ), 20, 3 );
require_once dirname(__FILE__) . '/action_caller.php';
