Webseite-Freund-des-Spessarts/theme/friends-spessart/functions.php

50 lines
2.4 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function fds_theme_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'html5', array( 'search-form', 'gallery', 'caption', 'style', 'script' ) );
add_theme_support( 'custom-logo' );
register_nav_menus( array(
'primary' => __( 'Hauptmenue', 'friends-spessart' ),
) );
add_image_size( 'fds-teaser', 600, 600, true );
add_image_size( 'fds-hero', 1920, 1080, true );
}
add_action( 'after_setup_theme', 'fds_theme_setup' );
function fds_enqueue_assets() {
$css_path = get_stylesheet_directory() . '/assets/css/main.css';
$js_path = get_stylesheet_directory() . '/assets/js/main.js';
wp_enqueue_style( 'fds-style', get_stylesheet_directory_uri() . '/assets/css/main.css', array(), file_exists( $css_path ) ? filemtime( $css_path ) : '1.0' );
wp_enqueue_script( 'fds-main', get_stylesheet_directory_uri() . '/assets/js/main.js', array(), file_exists( $js_path ) ? filemtime( $js_path ) : '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'fds_enqueue_assets' );
require get_theme_file_path( '/inc/custom-post-type-news.php' );
// Mitgliedsantrag-Formular nutzt eigene <div>-Struktur fuer Tabs/Panels;
// wpautop wuerde ungewollte <p>-Tags um Buttons/Shortcodes einfuegen.
add_filter( 'wpcf7_autop_or_not', '__return_false' );
// --- Design 2026 (docs/Input/Home Seite.pdf) ---------------------------------
if ( ! defined( 'FDS_FACEBOOK_URL' ) ) define( 'FDS_FACEBOOK_URL', 'https://facebook.com/NP3Spessart' );
// Instagram-Profil des Vereins noch unbekannt: leer = Icon wird nicht angezeigt.
if ( ! defined( 'FDS_INSTAGRAM_URL' ) ) define( 'FDS_INSTAGRAM_URL', '' );
function fds_enqueue_design_2026() {
$path = get_stylesheet_directory() . '/assets/css/design-2026.css';
wp_enqueue_style( 'fds-design-2026', get_stylesheet_directory_uri() . '/assets/css/design-2026.css', array( 'fds-style' ), file_exists( $path ) ? filemtime( $path ) : '1.0' );
}
add_action( 'wp_enqueue_scripts', 'fds_enqueue_design_2026', 20 );
function fds_preload_hero() {
if ( ! is_front_page() ) return;
$img = get_stylesheet_directory_uri() . '/assets/img/';
printf( '<link rel="preload" as="image" href="%1$shero-wald-1200.jpg?v=2" imagesrcset="%1$shero-wald-800.jpg?v=2 800w, %1$shero-wald-1200.jpg?v=2 1200w, %1$shero-wald-2400.jpg?v=2 2400w" imagesizes="100vw">' . "\n", esc_url( $img ) );
}
add_action( 'wp_head', 'fds_preload_hero', 1 );