diff --git a/Minecraft-Modern-Theme/functions.php b/Minecraft-Modern-Theme/functions.php index f4c1fdf..cb5df52 100644 --- a/Minecraft-Modern-Theme/functions.php +++ b/Minecraft-Modern-Theme/functions.php @@ -298,3 +298,94 @@ function load_faq_page_template( $template ) { } add_filter( 'template_include', 'load_faq_page_template' ); + +// ========================================================================= +// === CUSTOM LOGIN FUNCTIONS (KOMPLETT NEU & KORRIGIERT) ========== +// ========================================================================= + +// Lädt alle notwendigen Styles und Scripts nur für die Login-Seite +function minecraft_modern_login_assets() { + // Lade die Login-spezifische CSS + wp_enqueue_style('minecraft-modern-login-style', get_template_directory_uri() . '/css/login-style.css'); + + // Lade Font Awesome für Icons + wp_enqueue_style('font-awesome', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css'); + + // Lade das JavaScript für den Avatar-Slider + wp_enqueue_script('minecraft-avatar-slider-script', get_template_directory_uri() . '/js/login-slider.js', array('jquery'), '1.0', true); + + // Lade das JavaScript, das die HTML-Struktur anpasst + wp_enqueue_script('minecraft-modern-login-script', get_template_directory_uri() . '/js/login-script.js', array('jquery'), '1.0', true); + + wp_add_inline_script('minecraft-modern-login-script', " + jQuery(document).ready(function($) { + $('.forgetmenot, #nav').wrapAll('
'); + }); + "); + + // Übergebe die Slider-Geschwindigkeit aus dem Customizer an das JavaScript + $slider_speed = get_theme_mod('login_avatar_slider_speed', 4); // Standard: 4 Sekunden + wp_localize_script('minecraft-avatar-slider-script', 'avatarSliderSettings', array( + 'speed' => $slider_speed * 1000 // Umwandlung in Millisekunden für JS + )); + + // Hintergrundbild und Logo als Inline-CSS hinzufügen + $login_bg_image = get_theme_mod('login_background_image'); + if ($login_bg_image) { + $custom_css = "body.login { background-image: url('{$login_bg_image}') !important; }"; + wp_add_inline_style('minecraft-modern-login-style', $custom_css); + } + $logo_url = get_theme_mod('login_logo'); + if ($logo_url) { + $logo_css = ".login h1 a { background-image: url('{$logo_url}') !important; }"; + wp_add_inline_style('minecraft-modern-login-style', $logo_css); + } +} +add_action('login_enqueue_scripts', 'minecraft_modern_login_assets'); + +// Erstellt die HTML-Struktur für den Avatar-Slider +function add_minecraft_avatar_slider_to_login() { + $avatar_html = '
'; + $has_avatars = false; + + // Durchlaufe alle 5 möglichen Avatar-Plätze + for ($i = 1; $i <= 5; $i++) { + $uuid = get_theme_mod('login_avatar_uuid_' . $i); + if (!empty($uuid)) { + $has_avatars = true; + $avatar_url = "https://visage.surgeplay.com/full/{$uuid}.png"; + // Das erste Bild wird direkt angezeigt + $active_class = ($i === 1) ? 'avatar-slide-active' : ''; + $avatar_html .= 'Minecraft Avatar ' . ($i + 1) . ''; + } + } + $avatar_html .= '
'; + + // Nur den Slider ausgeben, wenn mindestens ein Avatar hinterlegt wurde + if ($has_avatars) { + echo $avatar_html; + } +} +add_action('login_form', 'add_minecraft_avatar_slider_to_login'); + +function add_post_login_links() { + ?> +
+ ← Zu +
+