<?php
declare(strict_types=1);
namespace MeinWeimar\Elementor;
use MeinWeimar\ContentTypes;
use MeinWeimar\Renderer;
final class BrandWidget extends \Elementor\Widget_Base
{
public function get_name(): string { return 'meinweimar_brand'; }
public function get_title(): string { return __('MeinWeimar Brand', 'meinweimar-core'); }
public function get_icon(): string { return 'eicon-logo'; }
public function get_categories(): array { return ['meinweimar']; }
protected function register_controls(): void
{
$this->start_controls_section('content', ['label' => __('Marke', 'meinweimar-core')]);
$this->add_control('wordmark', [
'label' => __('Wordmark überschreiben', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => '',
'description' => __('Leer lassen, um die globale WordPress-Konfiguration zu verwenden.', 'meinweimar-core'),
]);
$this->add_control('variant', [
'label' => __('Logo-Variante', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => [
'light' => __('Für helle Hintergründe', 'meinweimar-core'),
'dark' => __('Für dunkle Hintergründe', 'meinweimar-core'),
],
'default' => 'light',
]);
$this->end_controls_section();
}
protected function render(): void
{
echo Renderer::brand_markup([
'wordmark' => $this->get_settings_for_display('wordmark'),
'variant' => $this->get_settings_for_display('variant'),
]);
}
}
final class DiscoveryWidget extends \Elementor\Widget_Base
{
public function get_name(): string { return 'meinweimar_discovery'; }
public function get_title(): string { return __('MeinWeimar Discovery', 'meinweimar-core'); }
public function get_icon(): string { return 'eicon-map-pin'; }
public function get_categories(): array { return ['meinweimar']; }
protected function register_controls(): void
{
$this->start_controls_section('content', ['label' => __('Discovery', 'meinweimar-core')]);
$type_options = ['all' => __('Alle Ressourcen', 'meinweimar-core')];
foreach (ContentTypes::definitions() as $route => $definition) {
$type_options[$route] = $definition['label'];
}
$this->add_control('type', [
'label' => __('Inhaltstyp', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => $type_options,
'default' => 'places',
]);
$this->add_control('per_page', [
'label' => __('Ergebnisse', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::NUMBER,
'min' => 1,
'max' => 50,
'default' => 12,
]);
$this->add_control('search', [
'label' => __('Startsuche', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => '',
'description' => __('Optionaler Suchbegriff für den initialen REST-Aufruf.', 'meinweimar-core'),
]);
$this->add_control('category', [
'label' => __('Kategorie-Slug', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => '',
]);
$this->add_control('region', [
'label' => __('Region-Slug', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => '',
]);
$this->add_control('sort', [
'label' => __('Standardsortierung', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => [
'auto' => __('Automatisch', 'meinweimar-core'),
'distance' => __('Entfernung', 'meinweimar-core'),
'newest' => __('Neueste', 'meinweimar-core'),
'title' => __('Alphabetisch', 'meinweimar-core'),
],
'default' => 'auto',
]);
$this->add_control('radius_km', [
'label' => __('Standardradius (km)', 'meinweimar-core'),
'type' => \Elementor\Controls_Manager::NUMBER,
'min' => 1,
'max' => 100,
'step' => 1,
'default' => 10,
]);
$this->end_controls_section();
}
protected function render(): void
{
$settings = $this->get_settings_for_display();
echo Renderer::discovery_markup([
'type' => $settings['type'] ?? 'places',
'per_page' => $settings['per_page'] ?? 12,
'search' => $settings['search'] ?? '',
'category' => $settings['category'] ?? '',
'region' => $settings['region'] ?? '',
'sort' => $settings['sort'] ?? 'auto',
'radius_km' => $settings['radius_km'] ?? 10,
]);
}
}
