Minecraft-Modern-Theme/functions.php aktualisiert
This commit is contained in:
@@ -298,3 +298,94 @@ function load_faq_page_template( $template ) {
|
|||||||
}
|
}
|
||||||
add_filter( 'template_include', 'load_faq_page_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('<div class=\"login-options-container\"></div>');
|
||||||
|
});
|
||||||
|
");
|
||||||
|
|
||||||
|
// Ü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 = '<div id="minecraft-avatar-slider">';
|
||||||
|
$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 .= '<img class="avatar-slide ' . esc_attr($active_class) . '" src="' . esc_url($avatar_url) . '" alt="Minecraft Avatar ' . ($i + 1) . '">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$avatar_html .= '</div>';
|
||||||
|
|
||||||
|
// 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() {
|
||||||
|
?>
|
||||||
|
<div class="post-login-links">
|
||||||
|
<a href="<?php echo esc_url(home_url()); ?>">← Zu <?php bloginfo('name'); ?></a>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
add_action('login_form_bottom', 'add_post_login_links');
|
||||||
|
|
||||||
|
// Entfernt unnötige Elemente von der Login-Seite
|
||||||
|
function customize_login_page() {
|
||||||
|
add_filter('login_display_language_dropdown', '__return_false');
|
||||||
|
add_filter('login_display_back_to_blog', '__return_false');
|
||||||
|
}
|
||||||
|
add_action('login_head', 'customize_login_page');
|
||||||
|
|
||||||
|
// Passt Login-URL und Titel an
|
||||||
|
function custom_login_url() { return home_url(); }
|
||||||
|
add_filter('login_headerurl', 'custom_login_url');
|
||||||
|
function custom_login_title() { return get_bloginfo('name'); }
|
||||||
|
add_filter('login_headertext', 'custom_login_title');
|
||||||
Reference in New Issue
Block a user