Files
Workshop-Wahlen/konficastle-workshopwahl.php
Blitz08 67222fc6f9
All checks were successful
Deploy Workshop-Wahlen (DEV / PROD) / deploy (push) Successful in 11s
admin: add AJAX fallback for wahl phase count; use ajax in force-zuteilung JS
2026-01-31 11:45:36 +01:00

80 lines
3.4 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// AJAX endpoint to return wahl details (anzahl_einheiten)
add_action('wp_ajax_kc_get_wahl', function(){
global $wpdb;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if (!$id) {
wp_send_json_error('missing id');
}
$row = $wpdb->get_row($wpdb->prepare("SELECT id, COALESCE(anzahl_einheiten,1) as anzahl_einheiten FROM {$wpdb->prefix}kc_wahlen WHERE id=%d", $id));
if (!$row) wp_send_json_error('not found');
wp_send_json_success(['id'=>intval($row->id),'anzahl_einheiten'=>intval($row->anzahl_einheiten)]);
});
/**
* Plugin Name: Workshop-Wahlen
* Description: Workshop-Wahl-System für Konfi-Castle.com
* Version: 1.0
* Author: Linus Maximilian Nilson
*/
if (!defined('ABSPATH')) exit;
// Stylesheet einbinden
add_action('admin_enqueue_scripts', function($hook) {
// Nur auf den Plugin-Seiten laden (optional: prüfe $hook!)
if (strpos($hook, 'kc_') !== false) {
wp_enqueue_style(
'kc-admin-style',
plugin_dir_url(__FILE__) . 'assets/kc-admin-style.css',
[],
filemtime(plugin_dir_path(__FILE__) . 'assets/kc-admin-style.css')
);
}
});
add_action('admin_enqueue_scripts', function($hook) {
// Nur für unser Plugin-Menü!
if (strpos($hook, 'kc_') === false) return;
wp_enqueue_script('select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', ['jquery'], null, true);
wp_enqueue_style('select2', 'https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css');
});
add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('kc-workshopwahl-form', plugins_url('assets/frontend-form.css', __FILE__));
});
// Zentrale Admin-Menüstruktur
add_action('admin_menu', function() {
add_menu_page('Wahlen', 'Wahlen', 'manage_options', 'kc_wahlen', 'kc_wahlen_page');
add_submenu_page('kc_wahlen', 'Teamer', 'Teamer', 'manage_options', 'kc_teamer', 'kc_teamer_page');
add_submenu_page('kc_wahlen', 'Workshops', 'Workshops', 'manage_options', 'kc_workshops', 'kc_workshops_page');
add_submenu_page('kc_wahlen', 'Teilnehmer', 'Teilnehmer', 'manage_options', 'kc_teilnehmer', 'kc_teilnehmer_page');
add_submenu_page('kc_wahlen', 'Force-Zuteilung', 'Force-Zuteilung', 'manage_options', 'kc_force_zuteilung', 'kc_force_zuteilung_page');
add_submenu_page('kc_wahlen', 'Zuteilungen', 'Zuteilungen', 'manage_options', 'kc_zuteilungen', 'kc_zuteilungen_page');
// Data management (test data) - visible only to super-admin (we'll check inside page)
add_submenu_page('kc_wahlen', 'Datenverwaltung', 'Datenverwaltung', 'manage_options', 'kc_data', 'kc_data_page');
});
// Includes  jede Admin-Seite ruft oben kc_admin_tabs() auf!
require_once plugin_dir_path(__FILE__).'includes/admin-wahlen.php';
require_once plugin_dir_path(__FILE__).'includes/admin-workshops.php';
require_once plugin_dir_path(__FILE__).'includes/admin-teilnehmer.php';
require_once plugin_dir_path(__FILE__).'includes/admin-teamer.php';
require_once plugin_dir_path(__FILE__).'includes/force-zuteilung.php';
require_once plugin_dir_path(__FILE__).'includes/admin-zuteilungen.php';
require_once plugin_dir_path(__FILE__).'includes/frontend-form.php';
require_once plugin_dir_path(__FILE__).'includes/frontend-ergebnis.php';
require_once plugin_dir_path(__FILE__).'includes/zuteilungslogik.php';
require_once plugin_dir_path(__FILE__).'includes/admin-data.php';
require_once plugin_dir_path(__FILE__).'install.php';