<?php
/**
 * Plugin Name:  BdP Kompass
 * Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite
 * Version: 4.2.1
 * Tags: bdp, utility, helper
 * Requires at least: 6.0
 * Requires PHP: 8.2
 * Author: Thomas Günther
 * Author URI: https://www.sachsen.pfadfinden.de
 * Update URI: http://lv-sachsen-main.bdp.mein-verein.online/wordpress/
 * Text Domain: bdp-kompass
 */

use Bdp\Modules\LimitLoginAttempts\Controllers\OptionsPage as OptionsPageAlias;
use Bdp\Modules\Security\Security;
use Bdp\Modules\Seo\Seo;

require_once dirname(__FILE__) . '/includes/setup.php';

function bdp_plugin_install() {

}


function bdp_plugin_init() {
	Security::ProhibitBots();
	Security::SetPageFilters();

	if (null == get_option('kompass_already_installed', null)) {
		Seo::setup();
		Calendar::setup();
		Security::setup();
		update_option('kompass_already_installed', true);
		wp_redirect( 'site-health.php?tab=bdp_enhanced_security');
	}

}

add_action('admin_menu', function () {
	new OptionsPageAlias();
});


function register_custom_theme_directory() {
    $file = ABSPATH . '/wp-content/plugins/bdp-kompass/buena/' ;

    system('mkdir ' . ABSPATH . 'wp-content/themes/buena/');
    system('cp -r ' . $file . '* ' . ABSPATH . 'wp-content/themes/buena/');

    switch_theme('buena');
}

function enqueue_custom_password_js() {
	wp_enqueue_script( 'custom-password-js', BDP_LV_PLUGIN_URL . 'assets/password.js');
	wp_localize_script( 'custom-password-js', 'php_vars', [
		'allowed_strengths' => kompass_get_minimal_password_strength(),
		'password_too_short_text' => 'Dass Passwort entspricht nicht den Anforderungen.'
	]);
}

#add_action( 'after_setup_theme', 'register_custom_theme_directory' );