13 Commits
1.0 ... 1.1

9 changed files with 1474 additions and 1278 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -1,80 +1,92 @@
<?php get_header(); ?>
<?php
if ( get_theme_mod('slider_enabled', false) ) :
?>
<section class="hero-slider swiper-container">
<div class="swiper-wrapper">
<?php
for ($i = 1; $i <= 5; $i++) :
$image_url = get_theme_mod('slider_image_' . $i);
if ($image_url) :
$title = get_theme_mod('slider_title_' . $i);
$subtitle = get_theme_mod('slider_subtitle_' . $i);
?>
<div class="swiper-slide" style="background-image: url('<?php echo esc_url($image_url); ?>');">
<div class="slider-content">
<?php if ($title) : ?>
<h2 class="slider-title"><?php echo esc_html($title); ?></h2>
<?php endif; ?>
<?php if ($subtitle) : ?>
<p class="slider-subtitle"><?php echo esc_html($subtitle); ?></p>
<?php endif; ?>
</div>
</div>
<?php
endif;
endfor;
?>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</section>
<?php else : ?>
<?php
$hero_bg = get_theme_mod( 'hero_bg_image' );
$hero_title = get_theme_mod( 'hero_title', 'Willkommen auf unserem Server' );
$hero_subtitle = get_theme_mod( 'hero_subtitle', 'Trete einer Community voller Abenteuer bei.' );
$btn1_text = get_theme_mod( 'hero_button_1_text', 'Zum Forum' );
$btn1_url = get_theme_mod( 'hero_button_1_url', '#' );
$btn2_text = get_theme_mod( 'hero_button_2_text', 'Zum Teamspeak' );
$btn2_url = get_theme_mod( 'hero_button_2_url', '#' );
?>
<section class="hero-section" style="<?php echo $hero_bg ? "background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('" . esc_url($hero_bg) . "')" : ''; ?>">
<div class="container">
<h1 class="hero-title"><?php echo esc_html($hero_title); ?></h1>
<p class="hero-subtitle"><?php echo esc_html($hero_subtitle); ?></p>
<div class="hero-buttons">
<a href="<?php echo esc_url($btn1_url); ?>" class="hero-button-1"><?php echo esc_html($btn1_text); ?></a>
<a href="<?php echo esc_url($btn2_url); ?>" class="hero-button-2"><?php echo esc_html($btn2_text); ?></a>
</div>
</div>
</section>
<?php endif; ?>
<main id="primary" class="site-main">
<div class="container">
<div class="content-area">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium_large'); ?></a>
</div>
<?php endif; ?>
<div class="post-content">
<h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="post-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
</article>
<?php endwhile; else : ?>
<p><?php _e( 'Keine Beiträge gefunden.', 'minecraft-modern-theme' ); ?></p>
<?php endif; ?>
</div>
</div>
</main>
<?php get_header(); ?>
<?php
if ( get_theme_mod('slider_enabled', false) ) :
?>
<section class="hero-slider swiper-container">
<div class="swiper-wrapper">
<?php
for ($i = 1; $i <= 5; $i++) :
$image_url = get_theme_mod('slider_image_' . $i);
if ($image_url) :
$title = get_theme_mod('slider_title_' . $i);
$subtitle = get_theme_mod('slider_subtitle_' . $i);
?>
<div class="swiper-slide" style="background-image: url('<?php echo esc_url($image_url); ?>');">
<div class="slider-content">
<?php if ($title) : ?>
<h2 class="slider-title"><?php echo esc_html($title); ?></h2>
<?php endif; ?>
<?php if ($subtitle) : ?>
<p class="slider-subtitle"><?php echo esc_html($subtitle); ?></p>
<?php endif; ?>
</div>
</div>
<?php
endif;
endfor;
?>
</div>
<!-- Nur anzeigen, wenn die Paginierung NICHT ausgeblendet ist -->
<?php if ( ! get_theme_mod('slider_hide_pagination', false) ) : ?>
<div class="swiper-pagination"></div>
<?php endif; ?>
<!-- Nur anzeigen, wenn die Pfeile NICHT ausgeblendet sind -->
<?php if ( ! get_theme_mod('slider_hide_arrows', false) ) : ?>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php endif; ?>
</section>
<?php else : ?>
<?php
$hero_bg = get_theme_mod( 'hero_bg_image' );
$hero_title = get_theme_mod( 'hero_title', 'Willkommen auf unserem Server' );
$hero_subtitle = get_theme_mod( 'hero_subtitle', 'Trete einer Community voller Abenteuer bei.' );
$btn1_text = get_theme_mod( 'hero_button_1_text', 'Zum Forum' );
$btn1_url = get_theme_mod( 'hero_button_1_url', '#' );
$btn2_text = get_theme_mod( 'hero_button_2_text', 'Zum Teamspeak' );
$btn2_url = get_theme_mod( 'hero_button_2_url', '#' );
?>
<section class="hero-section" style="<?php echo $hero_bg ? "background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('" . esc_url($hero_bg) . "')" : ''; ?>">
<div class="container">
<h1 class="hero-title"><?php echo esc_html($hero_title); ?></h1>
<p class="hero-subtitle"><?php echo esc_html($hero_subtitle); ?></p>
<div class="hero-buttons">
<a href="<?php echo esc_url($btn1_url); ?>" class="hero-button-1"><?php echo esc_html($btn1_text); ?></a>
<a href="<?php echo esc_url($btn2_url); ?>" class="hero-button-2"><?php echo esc_html($btn2_text); ?></a>
</div>
</div>
</section>
<?php endif; ?>
<main id="primary" class="site-main">
<div class="container">
<div class="content-area">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('post'); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium_large'); ?></a>
</div>
<?php endif; ?>
<div class="post-content">
<h2 class="post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<!-- =================================================================== -->
<!-- === HIER IST DIE ÄNDERUNG: Vollen Inhalt anstelle des Auszugs === -->
<!-- =================================================================== -->
<div class="post-full-content">
<?php the_content(); ?>
</div>
</div>
</article>
<?php endwhile; else : ?>
<p><?php _e( 'Keine Beiträge gefunden.', 'minecraft-modern-theme' ); ?></p>
<?php endif; ?>
</div>
</div>
</main>
<?php get_footer(); ?>

View File

@@ -1,240 +1,300 @@
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// === Theme Setup ===
function minecraft_modern_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
// Logo-Unterstützung aktivieren (Maximale Flexibilität)
add_theme_support( 'custom-logo', array(
'height' => 9999, // Sehr hohe Werte, um den Crop-Dialog zu umgehen
'width' => 9999, // Sehr hohe Werte, um den Crop-Dialog zu umgehen
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
// Benutzerdefinierten Hintergrund aktivieren
add_theme_support( 'custom-background' );
register_nav_menus( array(
'primary' => __( 'Hauptmenü', 'minecraft-modern-theme' ),
'footer' => __( 'Footer-Menü', 'minecraft-modern-theme' ),
) );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
}
add_action( 'after_setup_theme', 'minecraft_modern_setup' );
// === Styles & Scripts laden ===
function minecraft_modern_scripts() {
// Haupt-Stylesheet
wp_enqueue_style( 'minecraft-modern-style', get_stylesheet_uri() );
// Swiper.js CSS (von CDN)
wp_enqueue_style( 'swiper-css', 'https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css' );
// JavaScript für den Header-Scroll-Effekt
wp_enqueue_script(
'minecraft-modern-header-script',
get_template_directory_uri() . '/js/header-scroll.js',
array(),
'1.0',
true
);
// Swiper.js JS (von CDN)
wp_enqueue_script(
'swiper-js',
'https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js',
array(),
'8.0.0',
true
);
// Unsere eigene Slider-Initialisierungs-Datei
wp_enqueue_script(
'minecraft-modern-slider-script',
get_template_directory_uri() . '/js/slider-init.js',
array('swiper-js'), // Hängt von Swiper.js ab
'1.0',
true
);
// NEU: Theme-Toggle-Skript laden
wp_enqueue_script(
'theme-toggle-script',
get_template_directory_uri() . '/js/theme-toggle.js',
array(), // Keine Abhängigkeiten
'1.0',
true
);
// FAQ Skript laden, wenn der Post-Type aktiv ist
if ( post_type_exists('faq') ) {
wp_enqueue_script(
'faq-accordion-script',
get_template_directory_uri() . '/js/faq-accordion.js',
array(),
'1.0',
true
);
}
// Übergebe ALLE Theme-Einstellungen an das JavaScript
// KORREKTUR: Der Objektname muss 'sliderSettings' bleiben, damit slider-init.js funktioniert.
wp_localize_script(
'minecraft-modern-slider-script',
'sliderSettings',
array(
'hideArrows' => get_theme_mod( 'slider_hide_arrows', false ) ? '1' : '0',
'hidePagination' => get_theme_mod( 'slider_hide_pagination', false ) ? '1' : '0',
'defaultMode' => get_theme_mod( 'default_theme_mode', 'dark' ),
'ajax_url' => admin_url('admin-ajax.php')
)
);
// === NEU & WICHTIG: Header-Skript-Informationen übergeben ===
// Dies verhindert das Flackern im Customizer.
wp_localize_script(
'minecraft-modern-header-script', // <-- Richtiges Skript-Handle!
'headerSettings', // <-- Neuer Objektname für Klarheit
array(
'isCustomizer' => is_customize_preview()
)
);
}
add_action( 'wp_enqueue_scripts', 'minecraft_modern_scripts' );
// === Customizer-Datei laden ===
require get_template_directory() . '/inc/customizer.php';
// === Footer-Widgets registrieren ===
function minecraft_modern_footer_widgets() {
register_sidebar( array(
'name' => __( 'Footer Links', 'minecraft-modern-theme' ),
'id' => 'footer-left',
'description' => __( 'Widget-Bereich links im Footer.', 'minecraft-modern-theme' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
for ( $i = 1; $i <= 3; $i++ ) {
register_sidebar( array(
'name' => sprintf( __( 'Footer Spalte %d', 'minecraft-modern-theme' ), $i ),
'id' => 'footer-' . $i,
'description' => sprintf( __( 'Widget für die %d. Spalte im Footer.', 'minecraft-modern-theme' ), $i ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
register_sidebar( array(
'name' => __( 'Footer Rechts', 'minecraft-modern-theme' ),
'id' => 'footer-right',
'description' => __( 'Widget-Bereich rechts im Footer.', 'minecraft-modern-theme' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
add_action( 'widgets_init', 'minecraft_modern_footer_widgets' );
// === FAQ Custom Post Type & Taxonomy ===
function create_faq_post_type() {
// Nur registrieren, wenn im Customizer aktiviert
if ( get_theme_mod( 'faq_enabled', true ) ) {
register_post_type('faq',
array(
'labels' => array(
'name' => __( 'FAQs', 'minecraft-modern-theme' ),
'singular_name' => __( 'FAQ', 'minecraft-modern-theme' ),
'add_new' => __( 'Neue FAQ hinzufügen', 'minecraft-modern-theme' ),
'add_new_item' => __( 'Neue FAQ hinzufügen', 'minecraft-modern-theme' ),
'edit_item' => __( 'FAQ bearbeiten', 'minecraft-modern-theme' ),
'new_item' => __( 'Neue FAQ', 'minecraft-modern-theme' ),
'view_item' => __( 'FAQ ansehen', 'minecraft-modern-theme' ),
'search_items' => __( 'FAQs durchsuchen', 'minecraft-modern-theme' ),
'not_found' => __( 'Keine FAQs gefunden', 'minecraft-modern-theme' ),
'not_found_in_trash' => __( 'Keine FAQs im Papierkorb gefunden', 'minecraft-modern-theme' ),
'all_items' => __( 'Alle FAQs', 'minecraft-modern-theme' ),
),
'public' => true,
'has_archive' => true, // Archiv-Seite /faq/ bleibt als Fallback
'menu_icon' => 'dashicons-format-chat',
'supports' => array( 'title', 'editor', 'page-attributes' ),
'rewrite' => array( 'slug' => 'faq' ),
'show_in_rest' => true,
)
);
register_taxonomy(
'faq_category',
'faq',
array(
'label' => __( 'FAQ Kategorien', 'minecraft-modern-theme' ),
'rewrite' => array( 'slug' => 'faq-kategorie' ),
'hierarchical' => true,
'show_in_rest' => true,
)
);
}
}
add_action('init', 'create_faq_post_type');
// =============================================================================
// NEU: Automatische FAQ-Seitenerstellung und Template-Zuweisung
// =============================================================================
/**
* Erstellt automatisch eine "FAQ" Seite, wenn die FAQ-Funktion aktiviert wird.
*/
function create_faq_page_automatically() {
// Prüfen, ob die FAQ-Funktion aktiv ist
if ( get_theme_mod( 'faq_enabled', true ) ) {
// Prüfen, ob die Seite bereits existiert
if ( get_page_by_title( 'FAQ' ) == null ) {
// Seite erstellen
$new_page = array(
'post_title' => 'FAQ',
'post_content' => 'Diese Seite zeigt alle FAQs an. Der Inhalt wird automatisch generiert.',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
);
// Seite in die Datenbank einfügen
wp_insert_post( $new_page );
}
}
}
// Diese Funktion wird ausgeführt, wenn der Customizer gespeichert wird.
add_action( 'customize_save_after', 'create_faq_page_automatically' );
/**
* Leitet Anfragen für die "FAQ" Seite auf unser spezielles Template um.
*/
function load_faq_page_template( $template ) {
// Prüfen, ob die FAQ-Funktion aktiv ist
if ( get_theme_mod( 'faq_enabled', true ) ) {
// Prüfen, ob wir uns auf einer Seite befinden
if ( is_page() ) {
global $post;
// Prüfen, ob der Titel der Seite "FAQ" ist
if ( $post && $post->post_title == 'FAQ' ) {
// Pfad zu unserem Template zurückgeben
return get_template_directory() . '/archive-faq.php';
}
}
}
// Standard-Template in allen anderen Fällen
return $template;
}
add_filter( 'template_include', 'load_faq_page_template' );
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// === Theme Setup ===
function minecraft_modern_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
// Logo-Unterstützung aktivieren (Maximale Flexibilität)
add_theme_support( 'custom-logo', array(
'height' => 9999, // Sehr hohe Werte, um den Crop-Dialog zu umgehen
'width' => 9999, // Sehr hohe Werte, um den Crop-Dialog zu umgehen
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
// Benutzerdefinierten Hintergrund aktivieren
add_theme_support( 'custom-background' );
register_nav_menus( array(
'primary' => __( 'Hauptmenü', 'minecraft-modern-theme' ),
'footer' => __( 'Footer-Menü', 'minecraft-modern-theme' ),
) );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
}
add_action( 'after_setup_theme', 'minecraft_modern_setup' );
// === Styles & Scripts laden ===
function minecraft_modern_scripts() {
// Haupt-Stylesheet
wp_enqueue_style( 'minecraft-modern-style', get_stylesheet_uri() );
// Swiper.js CSS (von CDN)
wp_enqueue_style( 'swiper-css', 'https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css' );
// JavaScript für den Header-Scroll-Effekt
wp_enqueue_script(
'minecraft-modern-header-script',
get_template_directory_uri() . '/js/header-scroll.js',
array(),
'1.0',
true
);
// NEU: Ankündigungs-Skript laden
wp_enqueue_script(
'announcement-script',
get_template_directory_uri() . '/js/announcement.js',
array(), // Keine Abhängigkeiten
'1.0',
true
);
// Swiper.js JS (von CDN)
wp_enqueue_script(
'swiper-js',
'https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js',
array(),
'8.0.0',
true
);
// Unsere eigene Slider-Initialisierungs-Datei
wp_enqueue_script(
'minecraft-modern-slider-script',
get_template_directory_uri() . '/js/slider-init.js',
array('swiper-js'), // Hängt von Swiper.js ab
'1.0',
true
);
// NEU: Theme-Toggle-Skript laden
wp_enqueue_script(
'theme-toggle-script',
get_template_directory_uri() . '/js/theme-toggle.js',
array(), // Keine Abhängigkeiten
'1.0',
true
);
// FAQ Skript laden, wenn der Post-Type aktiv ist
if ( post_type_exists('faq') ) {
wp_enqueue_script(
'faq-accordion-script',
get_template_directory_uri() . '/js/faq-accordion.js',
array(),
'1.0',
true
);
}
// Übergebe ALLE Theme-Einstellungen an das JavaScript
wp_localize_script(
'minecraft-modern-slider-script',
'sliderSettings',
array(
'hideArrows' => get_theme_mod( 'slider_hide_arrows', false ) ? '1' : '0',
'hidePagination' => get_theme_mod( 'slider_hide_pagination', false ) ? '1' : '0',
'effect' => get_theme_mod( 'slider_effect', 'fade' ),
'direction' => get_theme_mod( 'slider_direction', 'horizontal' ),
'defaultMode' => get_theme_mod( 'default_theme_mode', 'dark' ),
'ajax_url' => admin_url('admin-ajax.php')
)
);
// === NEU & WICHTIG: Header-Skript-Informationen übergeben ===
// Dies verhindert das Flackern im Customizer.
wp_localize_script(
'minecraft-modern-header-script', // <-- Richtiges Skript-Handle!
'headerSettings', // <-- Neuer Objektname für Klarheit
array(
'isCustomizer' => is_customize_preview()
)
);
}
add_action( 'wp_enqueue_scripts', 'minecraft_modern_scripts' );
// === Customizer-Datei laden ===
require get_template_directory() . '/inc/customizer.php';
// === Footer-Widgets registrieren ===
function minecraft_modern_footer_widgets() {
register_sidebar( array(
'name' => __( 'Footer Links', 'minecraft-modern-theme' ),
'id' => 'footer-left',
'description' => __( 'Widget-Bereich links im Footer.', 'minecraft-modern-theme' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
for ( $i = 1; $i <= 3; $i++ ) {
register_sidebar( array(
'name' => sprintf( __( 'Footer Spalte %d', 'minecraft-modern-theme' ), $i ),
'id' => 'footer-' . $i,
'description' => sprintf( __( 'Widget für die %d. Spalte im Footer.', 'minecraft-modern-theme' ), $i ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
register_sidebar( array(
'name' => __( 'Footer Rechts', 'minecraft-modern-theme' ),
'id' => 'footer-right',
'description' => __( 'Widget-Bereich rechts im Footer.', 'minecraft-modern-theme' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
) );
}
add_action( 'widgets_init', 'minecraft_modern_footer_widgets' );
// === FAQ Custom Post Type & Taxonomy ===
function create_faq_post_type() {
// Nur registrieren, wenn im Customizer aktiviert
if ( get_theme_mod( 'faq_enabled', true ) ) {
register_post_type('faq',
array(
'labels' => array(
'name' => __( 'FAQs', 'minecraft-modern-theme' ),
'singular_name' => __( 'FAQ', 'minecraft-modern-theme' ),
'add_new' => __( 'Neue FAQ hinzufügen', 'minecraft-modern-theme' ),
'add_new_item' => __( 'Neue FAQ hinzufügen', 'minecraft-modern-theme' ),
'edit_item' => __( 'FAQ bearbeiten', 'minecraft-modern-theme' ),
'new_item' => __( 'Neue FAQ', 'minecraft-modern-theme' ),
'view_item' => __( 'FAQ ansehen', 'minecraft-modern-theme' ),
'search_items' => __( 'FAQs durchsuchen', 'minecraft-modern-theme' ),
'not_found' => __( 'Keine FAQs gefunden', 'minecraft-modern-theme' ),
'not_found_in_trash' => __( 'Keine FAQs im Papierkorb gefunden', 'minecraft-modern-theme' ),
'all_items' => __( 'Alle FAQs', 'minecraft-modern-theme' ),
),
'public' => true,
'has_archive' => true, // Archiv-Seite /faq/ bleibt als Fallback
'menu_icon' => 'dashicons-format-chat',
'supports' => array( 'title', 'editor', 'page-attributes' ),
'rewrite' => array( 'slug' => 'faq' ),
'show_in_rest' => true,
)
);
register_taxonomy(
'faq_category',
'faq',
array(
'label' => __( 'FAQ Kategorien', 'minecraft-modern-theme' ),
'rewrite' => array( 'slug' => 'faq-kategorie' ),
'hierarchical' => true,
'show_in_rest' => true,
)
);
}
}
add_action('init', 'create_faq_post_type');
// =============================================================================
// NEU: Automatische "Home" Seitenerstellung und Zuweisung (kombiniert)
// =============================================================================
/**
* Erstellt die "Home" Seite und weist sie automatisch als statische Startseite zu,
* wenn das Theme aktiviert wird und noch keine Seite festgelegt ist.
*/
function set_static_front_page_automatically() {
// Nur ausführen, wenn noch keine statische Seite als Startseite festgelegt ist
if ( 'page' !== get_option( 'show_on_front' ) ) {
// Finde die "Home" Seite (oder erstelle sie, falls sie nicht existiert)
$home_page = get_page_by_title( 'Home' );
if ( ! $home_page ) {
// Seite erstellen, falls sie nicht existiert
$home_page_id = wp_insert_post( array(
'post_title' => 'Home',
'post_content' => 'Diese Seite dient als statische Startseite.',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
) );
} else {
$home_page_id = $home_page->ID;
}
// Setze die Seite als statische Startseite
if ( $home_page_id ) {
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $home_page_id );
}
}
}
add_action( 'after_switch_theme', 'set_static_front_page_automatically' );
/**
* Fügt eine Body-Klasse hinzu, um den Home-Titel per CSS auszublenden.
*/
function add_home_body_class( $classes ) {
// Prüfen, ob wir auf der Startseite sind und die Einstellung zum Ausblenden aktiv ist
if ( is_front_page() && !get_theme_mod( 'show_home_title', true ) ) {
$classes[] = 'home-title-hidden';
}
return $classes;
}
add_filter( 'body_class', 'add_home_body_class' );
// =============================================================================
// Automatische FAQ-Seitenerstellung und Template-Zuweisung
// =============================================================================
/**
* Erstellt automatisch eine "FAQ" Seite, wenn die FAQ-Funktion aktiviert wird.
*/
function create_faq_page_automatically() {
// Prüfen, ob die FAQ-Funktion aktiv ist
if ( get_theme_mod( 'faq_enabled', true ) ) {
// Prüfen, ob die Seite bereits existiert
if ( get_page_by_title( 'FAQ' ) == null ) {
// Seite erstellen
$new_page = array(
'post_title' => 'FAQ',
'post_content' => 'Diese Seite zeigt alle FAQs an. Der Inhalt wird automatisch generiert.',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
);
// Seite in die Datenbank einfügen
wp_insert_post( $new_page );
}
}
}
// Diese Funktion wird ausgeführt, wenn der Customizer gespeichert wird.
add_action( 'customize_save_after', 'create_faq_page_automatically' );
/**
* Leitet Anfragen für die "FAQ" Seite auf unser spezielles Template um.
*/
function load_faq_page_template( $template ) {
// Prüfen, ob die FAQ-Funktion aktiv ist
if ( get_theme_mod( 'faq_enabled', true ) ) {
// Prüfen, ob wir uns auf einer Seite befinden
if ( is_page() ) {
global $post;
// Prüfen, ob der Titel der Seite "FAQ" ist
if ( $post && $post->post_title == 'FAQ' ) {
// Pfad zu unserem Template zurückgeben
return get_template_directory() . '/archive-faq.php';
}
}
}
// Standard-Template in allen anderen Fällen
return $template;
}
add_filter( 'template_include', 'load_faq_page_template' );

View File

@@ -1,67 +1,65 @@
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header id="masthead" class="site-header">
<div class="container">
<div class="header-main">
<div class="site-branding">
<?php
// Zeigt das Logo an, wenn eines vorhanden ist.
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
the_custom_logo();
}
?>
<?php
// Zeigt den Titel der Website IMMER an.
// Verwendet <h1> auf der Startseite, sonst <p> für bessere SEO.
if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
</div>
<nav id="site-navigation" class="main-navigation">
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false ) ); ?>
</nav>
<div class="header-info">
<div class="social-links">
<?php
// Array mit den Social-Media-Plattformen und ihren Font Awesome Klassen
$social_icons = array(
'discord' => 'fab fa-discord',
'youtube' => 'fab fa-youtube',
'twitter' => 'fab fa-x-twitter', // Neues Icon für Twitter/X
'facebook' => 'fab fa-facebook-f',
'instagram' => 'fab fa-instagram',
'tiktok' => 'fab fa-tiktok',
'twitch' => 'fab fa-twitch',
'steam' => 'fab fa-steam',
'github' => 'fab fa-github',
'linkedin' => 'fab fa-linkedin-in',
'pinterest' => 'fab fa-pinterest-p',
'reddit' => 'fab fa-reddit-alien',
'teamspeak' => 'fab fa-teamspeak',
'spotify' => 'fab fa-spotify'
);
// Schleife, die alle verfügbaren Icons durchgeht
foreach ($social_icons as $key => $class) {
// Prüfen, ob für diese Plattform eine URL im Customizer hinterlegt wurde
if (get_theme_mod('social_' . $key)) {
// Wenn ja, Link und Icon ausgeben
echo '<a href="' . esc_url(get_theme_mod('social_' . $key)) . '" target="_blank"><i class="' . esc_attr($class) . '"></i></a>';
}
}
?>
</div>
</div>
</div>
</div>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header id="masthead" class="site-header">
<div class="container">
<div class="header-main">
<div class="site-branding">
<?php
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
the_custom_logo();
}
?>
<?php
if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
</div>
<nav id="site-navigation" class="main-navigation">
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false ) ); ?>
</nav>
<div class="header-info">
<div class="social-links">
<?php
// Array mit den Social-Media-Plattformen und ihren Font Awesome Klassen
$social_icons = array(
'discord' => 'fab fa-discord',
'youtube' => 'fab fa-youtube',
'twitter' => 'fab fa-x-twitter', // Neues Icon für Twitter/X
'facebook' => 'fab fa-facebook-f',
'instagram' => 'fab fa-instagram',
'tiktok' => 'fab fa-tiktok',
'twitch' => 'fab fa-twitch',
'steam' => 'fab fa-steam',
'github' => 'fab fa-github',
'linkedin' => 'fab fa-linkedin-in',
'pinterest' => 'fab fa-pinterest-p',
'reddit' => 'fab fa-reddit-alien',
'teamspeak' => 'fab fa-teamspeak',
'spotify' => 'fab fa-spotify'
);
// Schleife, die alle verfügbaren Icons durchgeht
foreach ($social_icons as $key => $class) {
// Prüfen, ob für diese Plattform eine URL im Customizer hinterlegt wurde
if (get_theme_mod('social_' . $key)) {
// Wenn ja, Link und Icon ausgeben
echo '<a href="' . esc_url(get_theme_mod('social_' . $key)) . '" target="_blank"><i class="' . esc_attr($class) . '"></i></a>';
}
}
?>
</div>
</div>
</div>
</div>
</header>

View File

@@ -1,258 +1,293 @@
<?php
function minecraft_modern_customize_register( $wp_customize ) {
// =========================================================================
// === 1. HEADER-BEREICH ===================================================
// =========================================================================
// --- Sektion: Header Slider ---
$wp_customize->add_section( 'header_slider', array(
'title' => 'Header Slider',
'priority' => 20,
'description' => 'Konfiguriere den großen Slider auf der Startseite.',
) );
// Checkbox zum Aktivieren des Sliders
$wp_customize->add_setting( 'slider_enabled', array(
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'slider_enabled', array(
'label' => 'Header Slider aktivieren',
'section' => 'header_slider',
'settings' => 'slider_enabled',
'type' => 'checkbox',
) );
// Dynamische Slider-Bilder, Titel und Untertitel
for ($i = 1; $i <= 5; $i++) {
$wp_customize->add_setting( 'slider_image_' . $i, array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'slider_image_' . $i, array(
'label' => sprintf( 'Banner %d - Bild', $i ),
'section' => 'header_slider',
'settings' => 'slider_image_' . $i,
) ) );
$wp_customize->add_setting( 'slider_title_' . $i, array( 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_title_' . $i, array(
'label' => sprintf( 'Banner %d - Titel', $i ),
'section' => 'header_slider',
'settings' => 'slider_title_' . $i,
'type' => 'text',
) );
$wp_customize->add_setting( 'slider_subtitle_' . $i, array( 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_subtitle_' . $i, array(
'label' => sprintf( 'Banner %d - Untertitel', $i ),
'section' => 'header_slider',
'settings' => 'slider_subtitle_' . $i,
'type' => 'text',
) );
}
// Slider Text- & Stil-Einstellungen
$wp_customize->add_setting( 'slider_font_family', array( 'default' => 'Raleway', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_font_family', array(
'label' => 'Schriftart', 'section' => 'header_slider', 'settings' => 'slider_font_family', 'type' => 'select',
'choices' => array( 'Raleway' => 'Raleway', 'Poppins' => 'Poppins', 'Montserrat' => 'Montserrat', 'Oswald' => 'Oswald', 'Roboto' => 'Roboto', 'Lato' => 'Lato' ),
) );
$wp_customize->add_setting( 'slider_font_size', array( 'default' => 'mittel', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_font_size', array(
'label' => 'Schriftgröße', 'section' => 'header_slider', 'settings' => 'slider_font_size', 'type' => 'select',
'choices' => array( 'klein' => 'Klein', 'mittel' => 'Mittel', 'gross' => 'Groß', 'extra-gross' => 'Extra Groß' ),
) );
$wp_customize->add_setting( 'slider_font_color', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color' ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'slider_font_color', array(
'label' => 'Schriftfarbe', 'section' => 'header_slider', 'settings' => 'slider_font_color',
) ) );
// === VERGESSENE EINSTELLUNG WIEDER HINZUGEFÜGT ===
$wp_customize->add_setting( 'header_height', array( 'default' => 'mittel', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'header_height', array(
'label' => 'Header-Höhe', 'section' => 'header_slider', 'settings' => 'header_height', 'type' => 'select',
'choices' => array( 'klein' => 'Klein', 'mittel' => 'Mittel', 'gross' => 'Groß' ),
) );
$wp_customize->add_setting( 'slider_hide_arrows', array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'slider_hide_arrows', array(
'label' => 'Pfeile ausblenden', 'section' => 'header_slider', 'settings' => 'slider_hide_arrows', 'type' => 'checkbox',
) );
$wp_customize->add_setting( 'slider_hide_pagination', array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'slider_hide_pagination', array(
'label' => 'Paginierung (Punkte) ausblenden', 'section' => 'header_slider', 'settings' => 'slider_hide_pagination', 'type' => 'checkbox',
) );
// --- Sektion: Startseiten-Hero (Fallback) ---
$wp_customize->add_section( 'hero_section', array(
'title' => 'Startseiten-Hero (wenn Slider deaktiviert)',
'priority' => 21,
'description' => 'Diese Inhalte werden angezeigt, wenn der Slider ausgeschaltet ist.',
) );
$wp_customize->add_setting( 'hero_title', array( 'default' => 'Willkommen auf unserem Server', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_title', array( 'label' => 'Haupttitel', 'section' => 'hero_section', 'settings' => 'hero_title', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_subtitle', array( 'default' => 'Trete einer Community voller Abenteuer bei.', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_subtitle', array( 'label' => 'Untertitel', 'section' => 'hero_section', 'settings' => 'hero_subtitle', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_bg_image', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'hero_bg_image', array(
'label' => 'Hintergrundbild', 'section' => 'hero_section', 'settings' => 'hero_bg_image',
) ) );
$wp_customize->add_setting( 'hero_button_1_text', array( 'default' => 'Zum Forum', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_button_1_text', array( 'label' => 'Button 1 Text', 'section' => 'hero_section', 'settings' => 'hero_button_1_text', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_button_1_url', array( 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'hero_button_1_url', array( 'label' => 'Button 1 URL', 'section' => 'hero_section', 'settings' => 'hero_button_1_url', 'type' => 'url' ) );
$wp_customize->add_setting( 'hero_button_2_text', array( 'default' => 'Zum Teamspeak', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_button_2_text', array( 'label' => 'Button 2 Text', 'section' => 'hero_section', 'settings' => 'hero_button_2_text', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_button_2_url', array( 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'hero_button_2_url', array( 'label' => 'Button 2 URL', 'section' => 'hero_section', 'settings' => 'hero_button_2_url', 'type' => 'url' ) );
// =========================================================================
// === 2. FARBEN & DARSTELLUNG (KOMBINIERT) ================================
// =========================================================================
// --- Sektion: Farben & Darstellung ---
$wp_customize->add_section( 'theme_appearance_settings', array(
'title' => 'Farben & Darstellung',
'priority' => 30,
) );
// Akzentfarbe
$wp_customize->add_setting( 'primary_accent_color', array( 'default' => '#00d4ff', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh' ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_accent_color', array(
'label' => 'Akzentfarbe', 'section' => 'theme_appearance_settings', 'settings' => 'primary_accent_color',
) ) );
// Hintergrundfarbe
$wp_customize->add_setting( 'background_color', array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_color', array(
'label' => 'Hintergrundfarbe',
'section' => 'theme_appearance_settings',
'settings' => 'background_color',
) ) );
// Dark / Light Mode
$wp_customize->add_setting( 'default_theme_mode', array( 'default' => 'dark', 'sanitize_callback' => 'sanitize_key' ) );
$wp_customize->add_control( 'default_theme_mode', array(
'label' => 'Standard-Theme-Modus', 'section' => 'theme_appearance_settings', 'type' => 'radio',
'choices' => array( 'dark' => 'Dark Mode (Standard)', 'light' => 'Light Mode' ),
) );
// =========================================================================
// === 3. SOCIAL MEDIA =====================================================
// =========================================================================
$wp_customize->add_section( 'social_links', array( 'title' => 'Social Media Links', 'priority' => 40 ) );
$social_platforms = array( 'discord' => 'Discord', 'youtube' => 'YouTube', 'twitter' => 'Twitter (X)', 'facebook' => 'Facebook', 'instagram' => 'Instagram', 'tiktok' => 'TikTok', 'twitch' => 'Twitch', 'steam' => 'Steam', 'github' => 'GitHub', 'linkedin' => 'LinkedIn', 'pinterest' => 'Pinterest', 'reddit' => 'Reddit', 'teamspeak' => 'Teamspeak', 'spotify' => 'Spotify' );
foreach ($social_platforms as $key => $label) {
$wp_customize->add_setting( 'social_' . $key, array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'social_' . $key, array(
'label' => $label . ' URL', 'section' => 'social_links', 'settings' => 'social_' . $key, 'type' => 'url',
) );
}
// =========================================================================
// === 4. FOOTER-BEREICH ==================================================
// =========================================================================
$wp_customize->add_section( 'footer_settings', array( 'title' => 'Footer-Einstellungen', 'priority' => 50 ) );
// Copyright-Text
$wp_customize->add_setting( 'footer_copyright', array( 'default' => '&copy; ' . date('Y') . ' ' . get_bloginfo('name'), 'sanitize_callback' => 'wp_kses_post' ) );
$wp_customize->add_control( 'footer_copyright', array(
'label' => 'Copyright-Text', 'section' => 'footer_settings', 'settings' => 'footer_copyright', 'type' => 'textarea',
) );
// Impressum & Datenschutz Links
$wp_customize->add_setting( 'footer_impressum_url', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'footer_impressum_url', array(
'label' => 'URL für Impressum', 'section' => 'footer_settings', 'settings' => 'footer_impressum_url', 'type' => 'url',
) );
$wp_customize->add_setting( 'footer_datenschutz_url', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'footer_datenschutz_url', array(
'label' => 'URL für Datenschutz', 'section' => 'footer_settings', 'settings' => 'footer_datenschutz_url', 'type' => 'url',
) );
// Footer-Credit
$wp_customize->add_setting( 'show_footer_credit', array( 'default' => true, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'show_footer_credit', array(
'label' => 'Footer-Credit ("Minecraft Theme Erstellt von...") anzeigen', 'section' => 'footer_settings', 'settings' => 'show_footer_credit', 'type' => 'checkbox',
) );
// =========================================================================
// === 5. ZUSÄTZLICHE FUNKTIONEN ==========================================
// =========================================================================
// --- Sektion: FAQ Einstellungen ---
$wp_customize->add_section( 'faq_settings', array( 'title' => 'FAQ Einstellungen', 'priority' => 60 ) );
$wp_customize->add_setting( 'faq_enabled', array( 'default' => true, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'faq_enabled', array(
'label' => 'FAQ System aktivieren', 'section' => 'faq_settings', 'settings' => 'faq_enabled', 'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'minecraft_modern_customize_register' );
// =========================================================================
// === DYNAMISCHES CSS =====================================================
// =========================================================================
// Diese Funktion bleibt unverändert, da sie bereits gut strukturiert ist.
function minecraft_modern_dynamic_css_output() {
$accent_color = get_theme_mod( 'primary_accent_color', '#00d4ff' );
$slider_font = get_theme_mod( 'slider_font_family', 'Raleway' );
$slider_color = get_theme_mod( 'slider_font_color', '#ffffff' );
$slider_size_setting = get_theme_mod( 'slider_font_size', 'mittel' );
$header_height_setting = get_theme_mod( 'header_height', 'mittel' ); // Diese Einstellung wird hier verwendet!
// Header-Höhe umwandeln
$header_height_value = '300px';
if ( $header_height_setting === 'klein' ) {
$header_height_value = '200px';
} elseif ( $header_height_setting === 'gross' ) {
$header_height_value = '400px';
}
// Schriftgrößen umwandeln
$font_sizes = array(
'klein' => array( 'title' => '2.5rem', 'subtitle' => '1.2rem' ),
'mittel' => array( 'title' => '3.5rem', 'subtitle' => '1.4rem' ),
'gross' => array( 'title' => '4.5rem', 'subtitle' => '1.6rem' ),
'extra-gross' => array( 'title' => '5.5rem', 'subtitle' => '1.8rem' ),
);
$chosen_sizes = isset( $font_sizes[$slider_size_setting] ) ? $font_sizes[$slider_size_setting] : $font_sizes['mittel'];
$fonts_to_load = array($slider_font);
$fonts_url = 'https://fonts.googleapis.com/css2?family=' . implode( ':wght@400;600;700&family=', $fonts_to_load ) . '&display=swap';
?>
<link rel="stylesheet" href="<?php echo esc_url($fonts_url); ?>">
<style type="text/css">
:root {
--primary-accent: <?php echo esc_attr($accent_color); ?>;
--header-height: <?php echo esc_attr($header_height_value); ?>;
}
.slider-title, .slider-subtitle, .hero-title, .hero-subtitle, .hero-button-1, .hero-button-2 {
font-family: '<?php echo esc_attr($slider_font); ?>', sans-serif;
color: <?php echo esc_attr($slider_color); ?>;
}
.slider-title, .hero-title {
font-size: <?php echo esc_attr($chosen_sizes['title']); ?>;
}
.slider-subtitle, .hero-subtitle {
font-size: <?php echo esc_attr($chosen_sizes['subtitle']); ?>;
}
</style>
<?php
}
add_action( 'wp_head', 'minecraft_modern_dynamic_css_output' );
<?php
function minecraft_modern_customize_register( $wp_customize ) {
// =========================================================================
// === 1. HEADER-BEREICH ===================================================
// =========================================================================
// --- Sektion: Header Slider ---
$wp_customize->add_section( 'header_slider', array(
'title' => 'Header Slider',
'priority' => 20,
'description' => 'Konfiguriere den großen Slider auf der Startseite.',
) );
// Checkbox zum Aktivieren des Sliders
$wp_customize->add_setting( 'slider_enabled', array(
'default' => false,
'transport' => 'refresh',
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'slider_enabled', array(
'label' => 'Header Slider aktivieren',
'section' => 'header_slider',
'settings' => 'slider_enabled',
'type' => 'checkbox',
) );
// Dynamische Slider-Bilder, Titel und Untertitel
for ($i = 1; $i <= 5; $i++) {
$wp_customize->add_setting( 'slider_image_' . $i, array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'slider_image_' . $i, array(
'label' => sprintf( 'Banner %d - Bild', $i ),
'section' => 'header_slider',
'settings' => 'slider_image_' . $i,
) ) );
$wp_customize->add_setting( 'slider_title_' . $i, array( 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_title_' . $i, array(
'label' => sprintf( 'Banner %d - Titel', $i ),
'section' => 'header_slider',
'settings' => 'slider_title_' . $i,
'type' => 'text',
) );
$wp_customize->add_setting( 'slider_subtitle_' . $i, array( 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_subtitle_' . $i, array(
'label' => sprintf( 'Banner %d - Untertitel', $i ),
'section' => 'header_slider',
'settings' => 'slider_subtitle_' . $i,
'type' => 'text',
) );
}
// Slider Text- & Stil-Einstellungen
$wp_customize->add_setting( 'slider_font_family', array( 'default' => 'Raleway', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_font_family', array(
'label' => 'Schriftart', 'section' => 'header_slider', 'settings' => 'slider_font_family', 'type' => 'select',
'choices' => array( 'Raleway' => 'Raleway', 'Poppins' => 'Poppins', 'Montserrat' => 'Montserrat', 'Oswald' => 'Oswald', 'Roboto' => 'Roboto', 'Lato' => 'Lato' ),
) );
$wp_customize->add_setting( 'slider_font_size', array( 'default' => 'mittel', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'slider_font_size', array(
'label' => 'Schriftgröße', 'section' => 'header_slider', 'settings' => 'slider_font_size', 'type' => 'select',
'choices' => array( 'klein' => 'Klein', 'mittel' => 'Mittel', 'gross' => 'Groß', 'extra-gross' => 'Extra Groß' ),
) );
$wp_customize->add_setting( 'slider_font_color', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color' ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'slider_font_color', array(
'label' => 'Schriftfarbe', 'section' => 'header_slider', 'settings' => 'slider_font_color',
) ) );
// === VERGESSENE EINSTELLUNG WIEDER HINZUGEFÜGT ===
$wp_customize->add_setting( 'header_height', array( 'default' => 'mittel', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'header_height', array(
'label' => 'Header-Höhe', 'section' => 'header_slider', 'settings' => 'header_height', 'type' => 'select',
'choices' => array( 'klein' => 'Klein', 'mittel' => 'Mittel', 'gross' => 'Groß' ),
) );
$wp_customize->add_setting( 'slider_hide_arrows', array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'slider_hide_arrows', array(
'label' => 'Pfeile ausblenden', 'section' => 'header_slider', 'settings' => 'slider_hide_arrows', 'type' => 'checkbox',
) );
$wp_customize->add_setting( 'slider_hide_pagination', array( 'default' => false, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'slider_hide_pagination', array(
'label' => 'Paginierung (Punkte) ausblenden', 'section' => 'header_slider', 'settings' => 'slider_hide_pagination', 'type' => 'checkbox',
) );
// =========================================================================
// === NEU: Slider-Effekt-Einstellungen ===================================
// =========================================================================
$wp_customize->add_setting( 'slider_effect', array( 'default' => 'fade', 'sanitize_callback' => 'sanitize_key' ) );
$wp_customize->add_control( 'slider_effect', array(
'label' => 'Slider-Effekt', 'section' => 'header_slider', 'settings' => 'slider_effect', 'type' => 'select',
'choices' => array( 'slide' => 'Horizontales Gleiten', 'fade' => 'Überblenden', 'cube' => 'Würfel-Effekt' ),
) );
$wp_customize->add_setting( 'slider_direction', array( 'default' => 'horizontal', 'sanitize_callback' => 'sanitize_key' ) );
$wp_customize->add_control( 'slider_direction', array(
'label' => 'Slider-Richtung (nur für "Gleiten")', 'section' => 'header_slider', 'settings' => 'slider_direction', 'type' => 'select',
'choices' => array( 'horizontal' => 'Horizontal', 'vertical' => 'Vertikal' ),
) );
// --- Sektion: Startseiten-Hero (Fallback) ---
$wp_customize->add_section( 'hero_section', array(
'title' => 'Startseiten-Hero (wenn Slider deaktiviert)',
'priority' => 21,
'description' => 'Diese Inhalte werden angezeigt, wenn der Slider ausgeschaltet ist.',
) );
$wp_customize->add_setting( 'hero_title', array( 'default' => 'Willkommen auf unserem Server', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_title', array( 'label' => 'Haupttitel', 'section' => 'hero_section', 'settings' => 'hero_title', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_subtitle', array( 'default' => 'Trete einer Community voller Abenteuer bei.', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_subtitle', array( 'label' => 'Untertitel', 'section' => 'hero_section', 'settings' => 'hero_subtitle', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_bg_image', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'hero_bg_image', array(
'label' => 'Hintergrundbild', 'section' => 'hero_section', 'settings' => 'hero_bg_image',
) ) );
$wp_customize->add_setting( 'hero_button_1_text', array( 'default' => 'Zum Forum', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_button_1_text', array( 'label' => 'Button 1 Text', 'section' => 'hero_section', 'settings' => 'hero_button_1_text', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_button_1_url', array( 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'hero_button_1_url', array( 'label' => 'Button 1 URL', 'section' => 'hero_section', 'settings' => 'hero_button_1_url', 'type' => 'url' ) );
$wp_customize->add_setting( 'hero_button_2_text', array( 'default' => 'Zum Teamspeak', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'hero_button_2_text', array( 'label' => 'Button 2 Text', 'section' => 'hero_section', 'settings' => 'hero_button_2_text', 'type' => 'text' ) );
$wp_customize->add_setting( 'hero_button_2_url', array( 'default' => '#', 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'hero_button_2_url', array( 'label' => 'Button 2 URL', 'section' => 'hero_section', 'settings' => 'hero_button_2_url', 'type' => 'url' ) );
// =========================================================================
// === 2. FARBEN & DARSTELLUNG (KOMBINIERT) ================================
// =========================================================================
// --- Sektion: Farben & Darstellung ---
$wp_customize->add_section( 'theme_appearance_settings', array(
'title' => 'Farben & Darstellung',
'priority' => 30,
) );
// Akzentfarbe
$wp_customize->add_setting( 'primary_accent_color', array( 'default' => '#00d4ff', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh' ) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_accent_color', array(
'label' => 'Akzentfarbe', 'section' => 'theme_appearance_settings', 'settings' => 'primary_accent_color',
) ) );
// Hintergrundfarbe
$wp_customize->add_setting( 'background_color', array(
'default' => '#ffffff',
'sanitize_callback' => 'sanitize_hex_color',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'background_color', array(
'label' => 'Hintergrundfarbe',
'section' => 'theme_appearance_settings',
'settings' => 'background_color',
) ) );
// Dark / Light Mode
$wp_customize->add_setting( 'default_theme_mode', array( 'default' => 'dark', 'sanitize_callback' => 'sanitize_key' ) );
$wp_customize->add_control( 'default_theme_mode', array(
'label' => 'Standard-Theme-Modus', 'section' => 'theme_appearance_settings', 'type' => 'radio',
'choices' => array( 'dark' => 'Dark Mode (Standard)', 'light' => 'Light Mode' ),
) );
// =========================================================================
// === 3. SOCIAL MEDIA =====================================================
// =========================================================================
$wp_customize->add_section( 'social_links', array( 'title' => 'Social Media Links', 'priority' => 40 ) );
$social_platforms = array( 'discord' => 'Discord', 'youtube' => 'YouTube', 'twitter' => 'Twitter (X)', 'facebook' => 'Facebook', 'instagram' => 'Instagram', 'tiktok' => 'TikTok', 'twitch' => 'Twitch', 'steam' => 'Steam', 'github' => 'GitHub', 'linkedin' => 'LinkedIn', 'pinterest' => 'Pinterest', 'reddit' => 'Reddit', 'teamspeak' => 'Teamspeak', 'spotify' => 'Spotify' );
foreach ($social_platforms as $key => $label) {
$wp_customize->add_setting( 'social_' . $key, array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'social_' . $key, array(
'label' => $label . ' URL', 'section' => 'social_links', 'settings' => 'social_' . $key, 'type' => 'url',
) );
}
// =========================================================================
// === 4. FOOTER-BEREICH ==================================================
// =========================================================================
$wp_customize->add_section( 'footer_settings', array( 'title' => 'Footer-Einstellungen', 'priority' => 50 ) );
// Copyright-Text
$wp_customize->add_setting( 'footer_copyright', array( 'default' => '&copy; ' . date('Y') . ' ' . get_bloginfo('name'), 'sanitize_callback' => 'wp_kses_post' ) );
$wp_customize->add_control( 'footer_copyright', array(
'label' => 'Copyright-Text', 'section' => 'footer_settings', 'settings' => 'footer_copyright', 'type' => 'textarea',
) );
// Impressum & Datenschutz Links
$wp_customize->add_setting( 'footer_impressum_url', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'footer_impressum_url', array(
'label' => 'URL für Impressum', 'section' => 'footer_settings', 'settings' => 'footer_impressum_url', 'type' => 'url',
) );
$wp_customize->add_setting( 'footer_datenschutz_url', array( 'sanitize_callback' => 'esc_url_raw' ) );
$wp_customize->add_control( 'footer_datenschutz_url', array(
'label' => 'URL für Datenschutz', 'section' => 'footer_settings', 'settings' => 'footer_datenschutz_url', 'type' => 'url',
) );
// Footer-Credit
$wp_customize->add_setting( 'show_footer_credit', array( 'default' => true, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'show_footer_credit', array(
'label' => 'Footer-Credit ("Minecraft Theme Erstellt von...") anzeigen', 'section' => 'footer_settings', 'settings' => 'show_footer_credit', 'type' => 'checkbox',
) );
// =========================================================================
// === 5. ZUSÄTZLICHE FUNKTIONEN ==========================================
// =========================================================================
// --- Sektion: FAQ Einstellungen ---
$wp_customize->add_section( 'faq_settings', array( 'title' => 'FAQ Einstellungen', 'priority' => 60 ) );
$wp_customize->add_setting( 'faq_enabled', array( 'default' => true, 'sanitize_callback' => 'wp_validate_boolean' ) );
$wp_customize->add_control( 'faq_enabled', array(
'label' => 'FAQ System aktivieren', 'section' => 'faq_settings', 'settings' => 'faq_enabled', 'type' => 'checkbox',
) );
}
add_action( 'customize_register', 'minecraft_modern_customize_register' );
// =========================================================================
// === DYNAMISCHES CSS =====================================================
// =========================================================================
function minecraft_modern_dynamic_css_output() {
$accent_color = get_theme_mod( 'primary_accent_color', '#00d4ff' );
$slider_font = get_theme_mod( 'slider_font_family', 'Raleway' );
$slider_color = get_theme_mod( 'slider_font_color', '#ffffff' );
$slider_size_setting = get_theme_mod( 'slider_font_size', 'mittel' );
$header_height_setting = get_theme_mod( 'header_height', 'mittel' ); // Diese Einstellung wird hier verwendet!
// Header-Höhe umwandeln
$header_height_value = '300px';
if ( $header_height_setting === 'klein' ) {
$header_height_value = '200px';
} elseif ( $header_height_setting === 'gross' ) {
$header_height_value = '400px';
}
// Schriftgrößen umwandeln
$font_sizes = array(
'klein' => array( 'title' => '2.5rem', 'subtitle' => '1.2rem' ),
'mittel' => array( 'title' => '3.5rem', 'subtitle' => '1.4rem' ),
'gross' => array( 'title' => '4.5rem', 'subtitle' => '1.6rem' ),
'extra-gross' => array( 'title' => '5.5rem', 'subtitle' => '1.8rem' ),
);
$chosen_sizes = isset( $font_sizes[$slider_size_setting] ) ? $font_sizes[$slider_size_setting] : $font_sizes['mittel'];
$fonts_to_load = array($slider_font);
$fonts_url = 'https://fonts.googleapis.com/css2?family=' . implode( ':wght@400;600;700&family=', $fonts_to_load ) . '&display=swap';
?>
<link rel="stylesheet" href="<?php echo esc_url($fonts_url); ?>">
<style type="text/css">
:root {
--primary-accent: <?php echo esc_attr($accent_color); ?>;
--header-height: <?php echo esc_attr($header_height_value); ?>;
}
.slider-title, .slider-subtitle, .hero-title, .hero-subtitle, .hero-button-1, .hero-button-2 {
font-family: '<?php echo esc_attr($slider_font); ?>', sans-serif;
color: <?php echo esc_attr($slider_color); ?>;
}
.slider-title, .hero-title {
font-size: <?php echo esc_attr($chosen_sizes['title']); ?>;
}
.slider-subtitle, .hero-subtitle {
font-size: <?php echo esc_attr($chosen_sizes['subtitle']); ?>;
}
/* =================================================================== */
/* === NEU: Trennlinien mit der Akzentfarbe ========================= */
/* =================================================================== */
/* Trennlinie unter dem Header */
.site-header {
border-bottom: 4px solid var(--primary-accent);
}
/* Trennlinie unter dem Slider */
.hero-slider {
border-bottom: 4px solid var(--primary-accent);
}
/* Trennlinie am oberen Rand des Footers */
.site-footer {
border-top: 4px solid var(--primary-accent);
}
</style>
<?php
}
add_action( 'wp_head', 'minecraft_modern_dynamic_css_output' );

View File

@@ -1,55 +1,65 @@
document.addEventListener('DOMContentLoaded', function() {
// Hole den Slider-Container
const heroSlider = document.querySelector('.hero-slider');
// Stelle sicher, dass der Slider auf der Seite existiert, bevor du versuchst, ihn zu konfigurieren
if (!heroSlider) {
return;
}
// Konfiguration für den Slider vorbereiten
const swiperConfig = {
// Optionen für den Slider
loop: true, // Endloses Schleifen
// Autoplay
autoplay: {
delay: 5000, // 5 Sekunden pro Slide
disableOnInteraction: false, // Autoplay nicht nach Klick stoppen
},
// Wenn der Nutzer die Maus darüber bewegt, pausieren
pauseOnMouseEnter: true,
// Effekt
effect: 'fade', // Übergangseffekt: 'slide', 'fade', 'cube', etc.
fadeEffect: {
crossFade: true
}
};
// Prüfe, ob die Pfeile ausgeblendet werden sollen
if (sliderSettings.hideArrows === '1') {
heroSlider.classList.add('slider-hide-arrows');
} else {
// Navigation nur hinzufügen, wenn sie nicht ausgeblendet wird
swiperConfig.navigation = {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
};
}
// Prüfe, ob die Paginierung ausgeblendet werden soll
if (sliderSettings.hidePagination === '1') {
heroSlider.classList.add('slider-hide-pagination');
} else {
// Pagination nur hinzufügen, wenn sie nicht ausgeblendet wird
swiperConfig.pagination = {
el: '.swiper-pagination',
clickable: true, // Klick auf Punkt springt zum Slide
};
}
// Initialisiere den Slider mit der konfigurierten Optionen
new Swiper('.hero-slider', swiperConfig);
});
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header id="masthead" class="site-header">
<div class="container">
<div class="header-main">
<div class="site-branding">
<?php
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
the_custom_logo();
}
?>
<?php
if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php else : ?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
</div>
<nav id="site-navigation" class="main-navigation">
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => false ) ); ?>
</nav>
<div class="header-info">
<div class="social-links">
<?php
// Array mit den Social-Media-Plattformen und ihren Font Awesome Klassen
$social_icons = array(
'discord' => 'fab fa-discord',
'youtube' => 'fab fa-youtube',
'twitter' => 'fab fa-x-twitter', // Neues Icon für Twitter/X
'facebook' => 'fab fa-facebook-f',
'instagram' => 'fab fa-instagram',
'tiktok' => 'fab fa-tiktok',
'twitch' => 'fab fa-twitch',
'steam' => 'fab fa-steam',
'github' => 'fab fa-github',
'linkedin' => 'fab fa-linkedin-in',
'pinterest' => 'fab fa-pinterest-p',
'reddit' => 'fab fa-reddit-alien',
'teamspeak' => 'fab fa-teamspeak',
'spotify' => 'fab fa-spotify'
);
// Schleife, die alle verfügbaren Icons durchgeht
foreach ($social_icons as $key => $class) {
// Prüfen, ob für diese Plattform eine URL im Customizer hinterlegt wurde
if (get_theme_mod('social_' . $key)) {
// Wenn ja, Link und Icon ausgeben
echo '<a href="' . esc_url(get_theme_mod('social_' . $key)) . '" target="_blank"><i class="' . esc_attr($class) . '"></i></a>';
}
}
?>
</div>
</div>
</div>
</div>
</header>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1 @@
# Minecraft-Modern-Theme
<img src="https://git.viper.ipv64.net/M_Viper/Minecraft-Modern-Theme/raw/branch/main/Minecraft-Modern-Theme/screenshot.PNG" alt="Backend" width="100%">