Files
Christoph Emsenhuber 7adbad7e63 Initial commit: Teilzeitladen WordPress Theme
- Custom Theme mit WooCommerce Support
- Responsive Design
- Notice Banner (Admin-gesteuert)
- Google Fonts Integration
- Platz für Unikate-Präsentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 19:31:47 +02:00

167 lines
4.6 KiB
PHP

<?php
/**
* Teilzeitladen Theme Functions
*
* @package Teilzeitladen
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Theme version
*/
define( 'TEILZEITLADEN_VERSION', '1.0.0' );
/**
* Enqueue scripts and styles
*/
function teilzeitladen_scripts() {
// Google Fonts
wp_enqueue_style(
'teilzeitladen-fonts',
'https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&family=Playfair+Display:wght@400;600&display=swap',
array(),
null
);
// Theme stylesheet
wp_enqueue_style(
'teilzeitladen-style',
get_stylesheet_uri(),
array(),
TEILZEITLADEN_VERSION
);
// Custom scripts
wp_enqueue_script(
'teilzeitladen-scripts',
get_template_directory_uri() . '/js/main.js',
array('jquery'),
TEILZEITLADEN_VERSION,
true
);
}
add_action( 'wp_enqueue_scripts', 'teilzeitladen_scripts' );
/**
* Theme setup
*/
function teilzeitladen_setup() {
// Add theme support
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'woocommerce' );
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
// Register menus
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'teilzeitladen' ),
'footer' => __( 'Footer Menu', 'teilzeitladen' ),
) );
// Image sizes
add_image_size( 'product-card', 400, 400, true );
add_image_size( 'hero', 1920, 600, true );
}
add_action( 'after_setup_theme', 'teilzeitladen_setup' );
/**
* WooCommerce support
*/
function teilzeitladen_woocommerce_setup() {
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
add_action( 'after_setup_theme', 'teilzeitladen_woocommerce_setup' );
/**
* Custom excerpt length
*/
function teilzeitladen_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'teilzeitladen_excerpt_length', 999 );
/**
* Notice Banner (Admin controlled)
*/
function teilzeitladen_notice_banner() {
$notice_text = get_theme_mod( 'teilzeitladen_notice_text', '' );
$notice_link = get_theme_mod( 'teilzeitladen_notice_link', '' );
$notice_enabled = get_theme_mod( 'teilzeitladen_notice_enabled', false );
if ( $notice_enabled && ! empty( $notice_text ) ) :
?>
<div class="notice-banner">
<div class="container">
<?php if ( ! empty( $notice_link ) ) : ?>
<a href="<?php echo esc_url( $notice_link ); ?>"><?php echo esc_html( $notice_text ); ?></a>
<?php else : ?>
<?php echo esc_html( $notice_text ); ?>
<?php endif; ?>
</div>
</div>
<?php
endif;
}
/**
* Customizer settings
*/
function teilzeitladen_customize_register( $wp_customize ) {
// Notice Banner Section
$wp_customize->add_section( 'teilzeitladen_notice', array(
'title' => __( 'Notice Banner', 'teilzeitladen' ),
'priority' => 30,
) );
$wp_customize->add_setting( 'teilzeitladen_notice_enabled', array(
'default' => false,
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'teilzeitladen_notice_enabled', array(
'label' => __( 'Enable Notice Banner', 'teilzeitladen' ),
'section' => 'teilzeitladen_notice',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'teilzeitladen_notice_text', array(
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( 'teilzeitladen_notice_text', array(
'label' => __( 'Notice Text', 'teilzeitladen' ),
'section' => 'teilzeitladen_notice',
'type' => 'text',
) );
$wp_customize->add_setting( 'teilzeitladen_notice_link', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'teilzeitladen_notice_link', array(
'label' => __( 'Notice Link (optional)', 'teilzeitladen' ),
'section' => 'teilzeitladen_notice',
'type' => 'url',
) );
}
add_action( 'customize_register', 'teilzeitladen_customize_register' );
/**
* Disable admin bar for non-admins
*/
function teilzeitladen_disable_admin_bar() {
if ( ! current_user_can( 'administrator' ) && ! is_admin() ) {
show_admin_bar( false );
}
}
add_action( 'after_setup_theme', 'teilzeitladen_disable_admin_bar' );