2023-12-30 14:28:21 +01:00
|
|
|
<?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
|
2024-10-31 12:55:40 +01:00
|
|
|
* Version: 4.10.1
|
2023-12-30 14:28:21 +01:00
|
|
|
* Tags: bdp, utility, helper
|
|
|
|
* Requires at least: 6.0
|
|
|
|
* Requires PHP: 8.2
|
|
|
|
* Author: Thomas Günther
|
|
|
|
* Author URI: https://www.sachsen.pfadfinden.de
|
2024-02-21 21:31:00 +01:00
|
|
|
* Update URI: http://lv-sachsen-main.bdp.mein-verein.online/wordpress/
|
2023-12-30 14:28:21 +01:00
|
|
|
* Text Domain: bdp-kompass
|
|
|
|
*/
|
|
|
|
|
2024-05-27 16:59:30 +02:00
|
|
|
use Bdp\Modules\EventParticipants\Controllers\MainController as EventsMain;
|
2024-03-16 14:21:57 +01:00
|
|
|
use Bdp\Modules\KompassSettings\Controllers\SettingsPage as KomnpassSettings;
|
2024-03-24 19:52:32 +01:00
|
|
|
use Bdp\Modules\Mail\Controllers\MailController;
|
2024-07-31 21:20:57 +02:00
|
|
|
use Bdp\Modules\Mail\Controllers\MailSettingsController;
|
2023-12-30 14:28:21 +01:00
|
|
|
use Bdp\Modules\Security\Security;
|
|
|
|
use Bdp\Modules\Seo\Seo;
|
2024-10-31 12:35:46 +01:00
|
|
|
use ProtectLogin\Modules\LimitLoginAttempts\Controllers\LoginHandler;
|
2023-12-30 14:28:21 +01:00
|
|
|
|
2024-02-21 21:31:00 +01:00
|
|
|
require_once dirname(__FILE__) . '/includes/setup.php';
|
2023-12-30 14:28:21 +01:00
|
|
|
|
|
|
|
function bdp_plugin_install() {
|
2024-02-27 11:33:24 +01:00
|
|
|
|
2023-12-30 14:28:21 +01:00
|
|
|
}
|
|
|
|
|
2024-02-21 21:31:00 +01:00
|
|
|
|
|
|
|
function bdp_plugin_init() {
|
2024-03-05 22:59:15 +01:00
|
|
|
bdp_kompass_load_plugin_textdomain();
|
2024-02-21 21:31:00 +01:00
|
|
|
Security::ProhibitBots();
|
|
|
|
Security::SetPageFilters();
|
|
|
|
|
2024-10-31 12:35:46 +01:00
|
|
|
if ( !file_exists( dirname( BDP_LV_STARTUP_FILE ) . '/../protect-login/protect-login.php' ) ) {
|
|
|
|
$allowed_ips = get_option('kompass_limit_login_allowlist', []);
|
|
|
|
$blocked_ips = get_option('kompass_limit_login_blocklist', []);
|
|
|
|
$lockouts = get_option('protect_login_limit_login_lockouts', []);
|
|
|
|
|
|
|
|
kompass_install_plugin('https://downloads.wordpress.org/plugin/protect-login.latest-stable.zip', 'protect-login');
|
|
|
|
|
|
|
|
update_option('protect_login_limit_login_blocklist', $blocked_ips);
|
|
|
|
update_option('protect_login_limit_login_allowlist', $allowed_ips);
|
|
|
|
foreach ($lockouts as $address => $duration) {
|
|
|
|
LoginHandler::lockout($address);
|
|
|
|
}
|
|
|
|
}
|
2024-08-12 15:48:55 +02:00
|
|
|
|
|
|
|
if (null == get_option('kompass_already_installed', null)) {
|
2024-02-27 11:33:24 +01:00
|
|
|
Seo::setup();
|
|
|
|
Security::setup();
|
|
|
|
update_option('kompass_already_installed', true);
|
2024-02-21 21:31:00 +01:00
|
|
|
wp_redirect( 'site-health.php?tab=bdp_enhanced_security');
|
|
|
|
}
|
2024-03-16 14:21:57 +01:00
|
|
|
Seo::importVerificationKeys();
|
2024-02-27 11:33:24 +01:00
|
|
|
|
2023-12-30 14:28:21 +01:00
|
|
|
}
|
|
|
|
|
2024-02-26 14:47:51 +01:00
|
|
|
add_action('admin_menu', function () {
|
2024-03-05 22:59:15 +01:00
|
|
|
bdp_kompass_load_plugin_textdomain();
|
2024-03-16 14:21:57 +01:00
|
|
|
new KomnpassSettings();
|
2024-05-27 16:59:30 +02:00
|
|
|
new EventsMain();
|
2024-03-24 19:52:32 +01:00
|
|
|
new MailController();
|
2024-05-27 16:59:30 +02:00
|
|
|
});
|
2024-09-22 21:46:14 +02:00
|
|
|
add_action('wp_ajax_bdp_kompass_show_ajax', 'bdp_kompass_load_ajax_content');
|
|
|
|
add_action('wp_ajax_nopriv_bdp_kompass_show_ajax', 'bdp_kompass_load_ajax_content');
|
2024-05-27 16:59:30 +02:00
|
|
|
|
2023-12-30 14:28:21 +01:00
|
|
|
function register_custom_theme_directory() {
|
2024-08-01 23:59:32 +02:00
|
|
|
if (is_dir(ABSPATH . '/wp-content/themes/mareike-theme/')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$file = ABSPATH . '/wp-content/plugins/bdp-kompass/lib/mareike-theme/' ;
|
2023-12-30 14:28:21 +01:00
|
|
|
|
2024-08-01 23:59:32 +02:00
|
|
|
system('mkdir ' . ABSPATH . '/wp-content/themes/mareike-theme/');
|
|
|
|
system('cp -r ' . $file . '* ' . ABSPATH . '/wp-content/themes/mareike-theme/');
|
2023-12-30 14:28:21 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-26 14:47:51 +01:00
|
|
|
function enqueue_custom_password_js() {
|
2024-05-27 16:59:30 +02:00
|
|
|
wp_enqueue_script( 'kompass-ajax', BDP_LV_PLUGIN_URL . '/assets/ajax.js');
|
2024-03-02 15:09:07 +01:00
|
|
|
wp_enqueue_script( 'searchable-table', BDP_LV_PLUGIN_URL . '/assets/searchtable.js');
|
2024-02-26 14:47:51 +01:00
|
|
|
}
|
|
|
|
|
2024-05-27 16:59:30 +02:00
|
|
|
|
2024-03-16 16:35:18 +01:00
|
|
|
add_action( 'after_setup_theme', 'kompass_after_setup_theme' );
|
2024-07-30 23:06:34 +02:00
|
|
|
|
2024-07-31 17:53:07 +02:00
|
|
|
add_action( 'admin_menu', ['Bdp\Modules\KompassSettings\Controllers\SettingsPage', 'add_menu'] );
|
2024-07-30 23:06:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function crp_custom_register_form() {
|
|
|
|
|
|
|
|
}
|
|
|
|
add_action('register_form', ['Bdp\Modules\Registration\Controllers\ExtendRegistrationForm', 'execute']);
|
|
|
|
|
|
|
|
// Validate registration form fields
|
|
|
|
add_filter('registration_errors', ['Bdp\Modules\Registration\Controllers\ExtendRegistrationForm', 'error_messages'], 10, 3);
|
|
|
|
|
|
|
|
// Save custom user meta data
|
|
|
|
add_action('user_register', ['\Bdp\Modules\Registration\Controllers\SaveRegistration', 'execute']);
|
|
|
|
|
|
|
|
// Handle account activation
|
|
|
|
|
|
|
|
add_action('init', ['Bdp\Modules\Registration\Controllers\SaveRegistration', 'activate_user']);
|
|
|
|
|
|
|
|
// Prevent login if account is not activated
|
|
|
|
|
|
|
|
add_filter('authenticate', ['Bdp\Modules\Registration\Controllers\SaveRegistration', 'check_user_activation'], 30, 3);
|
|
|
|
|
|
|
|
function crp_allow_umlauts_in_usernames($username, $raw_username, $strict) {
|
|
|
|
if (!$strict) {
|
|
|
|
return $username;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow letters, numbers, underscores, spaces, periods, hyphens, and umlauts
|
|
|
|
$username = preg_replace('/[^a-zA-Z0-9 _.\-äöüÄÖÜß]/', '', $raw_username);
|
|
|
|
|
|
|
|
return $username;
|
|
|
|
}
|
|
|
|
add_filter('sanitize_user', 'crp_allow_umlauts_in_usernames', 10, 3);
|
|
|
|
|
|
|
|
|
2024-07-31 17:53:07 +02:00
|
|
|
add_action('login_message', ['Bdp\Modules\Registration\Controllers\SaveRegistration','display_custom_message']);
|
|
|
|
|
|
|
|
if (false === (bool)get_option('user_can_register', false)) {
|
|
|
|
|
|
|
|
add_filter('registration_errors', 'kompass_disable_user_registration', 10, 3);
|
|
|
|
|
|
|
|
function kompass_disable_user_registration($errors, $sanitized_user_login, $user_email) {
|
|
|
|
$errors->add('registration_disabled', __('Die Registrierung ist derzeit deaktiviert.'));
|
|
|
|
return $errors;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action('login_enqueue_scripts', 'kompass_remove_register_link');
|
|
|
|
|
|
|
|
function kompass_remove_register_link() {
|
|
|
|
?>
|
|
|
|
<style>
|
|
|
|
#registerform {
|
|
|
|
display: none !important;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php
|
|
|
|
}
|
2024-07-31 21:20:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MailSettingsController::set_smtp_if_required();
|
2024-07-31 17:53:07 +02:00
|
|
|
|
|
|
|
|