generated from bisco/codex-bootstrap
218 lines
12 KiB
PHP
218 lines
12 KiB
PHP
<?php
|
||
/**
|
||
* Azione!Lab theme setup and editable homepage fields.
|
||
*/
|
||
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit;
|
||
}
|
||
|
||
function azionelab_defaults(): array {
|
||
return array(
|
||
'hero_title' => 'Il teatro diventa presenza.',
|
||
'hero_subtitle' => 'Un laboratorio dove corpo, voce, ascolto e relazione diventano scena.',
|
||
'hero_primary_label' => 'Vieni a conoscerci',
|
||
'hero_secondary_label'=> 'Guarda la galleria',
|
||
'intro_title' => 'Uno spazio per esserci davvero',
|
||
'intro_body' => 'Ogni incontro è uno spazio di pratica: si prova, si sbaglia, si ascolta, si ricomincia. Il gruppo diventa materia viva, la scena diventa occasione di scoperta.',
|
||
'laboratory_title' => 'Il laboratorio',
|
||
'laboratory_body' => 'Lavoriamo con il corpo, la voce e l’improvvisazione per allenare ascolto e presenza scenica. Attraverso esercizi individuali e di gruppo, ogni persona trova un modo autentico di stare nello spazio e nella relazione.',
|
||
'teacher_name' => 'Ernesto Estatico',
|
||
'teacher_bio' => 'Attore, regista e formatore, accompagna gruppi di ogni esperienza con cura e concretezza. Da oltre quindici anni conduce percorsi dedicati alla ricerca dell’autenticità scenica, intrecciando pedagogia teatrale, movimento e lavoro sulla voce.',
|
||
'teacher_quote' => 'Il teatro non è fingere: è imparare a essere presenti.',
|
||
'lesson_schedule' => 'Ogni martedì, dalle 20:00 alle 22:30',
|
||
'lesson_location' => "Spazio Teatro, Via dell'Epomeo 9999, Napoli",
|
||
'lesson_audience' => 'Adulti, con o senza esperienza',
|
||
'lesson_description' => 'Training fisico e vocale, improvvisazione, ascolto, costruzione del personaggio e lavoro di scena.',
|
||
'trial_lesson' => 'La prima lezione di prova è gratuita, su prenotazione.',
|
||
'lesson_notes' => 'Abiti comodi e calze antiscivolo consigliati.',
|
||
'contact_email' => 'ciao@azionelab.org',
|
||
'contact_phone' => '+39 333 123 4567',
|
||
'contact_whatsapp' => '+39 333 123 4567',
|
||
'contact_instagram' => 'https://instagram.com/',
|
||
'contact_facebook' => 'https://facebook.com/',
|
||
'contact_address' => "Via dell'Epomeo 9999, Napoli",
|
||
'footer_text' => 'Uno spazio aperto a chi desidera incontrare il teatro, insieme.',
|
||
);
|
||
}
|
||
|
||
function azionelab_mod( string $key ): string {
|
||
$defaults = azionelab_defaults();
|
||
return (string) get_theme_mod( $key, $defaults[ $key ] ?? '' );
|
||
}
|
||
|
||
function azionelab_asset( string $filename ): string {
|
||
return get_theme_file_uri( 'assets/images/' . $filename );
|
||
}
|
||
|
||
function azionelab_image( string $url, string $alt, array $attributes = array() ): string {
|
||
$attributes = array_merge(
|
||
array(
|
||
'alt' => $alt,
|
||
),
|
||
$attributes
|
||
);
|
||
|
||
$attachment_id = attachment_url_to_postid( $url );
|
||
if ( $attachment_id > 0 ) {
|
||
return wp_get_attachment_image( $attachment_id, 'large', false, $attributes ) ?: '';
|
||
}
|
||
|
||
$html_attributes = '';
|
||
foreach ( $attributes as $name => $value ) {
|
||
if ( '' === (string) $value ) {
|
||
continue;
|
||
}
|
||
$html_attributes .= sprintf( ' %s="%s"', esc_attr( $name ), esc_attr( (string) $value ) );
|
||
}
|
||
|
||
return sprintf( '<img src="%s"%s>', esc_url( $url ), $html_attributes );
|
||
}
|
||
|
||
function azionelab_phone_href( string $number ): string {
|
||
return preg_replace( '/[^0-9+]/', '', $number ) ?: '';
|
||
}
|
||
|
||
function azionelab_whatsapp_href( string $number ): string {
|
||
return preg_replace( '/[^0-9]/', '', $number ) ?: '';
|
||
}
|
||
|
||
function azionelab_social_icon( string $network ): string {
|
||
if ( 'instagram' === $network ) {
|
||
return '<svg class="social-icon social-icon-instagram" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><defs><linearGradient id="azl-instagram-gradient" x1="3" y1="21" x2="21" y2="3" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#feda75"/><stop offset="0.28" stop-color="#fa7e1e"/><stop offset="0.55" stop-color="#d62976"/><stop offset="0.78" stop-color="#962fbf"/><stop offset="1" stop-color="#4f5bd5"/></linearGradient></defs><rect x="3.6" y="3.6" width="16.8" height="16.8" rx="5.1" fill="url(#azl-instagram-gradient)"/><circle cx="12" cy="12" r="4.1" fill="none" stroke="#fff" stroke-width="1.9"/><circle cx="16.8" cy="7.35" r="1.15" fill="#fff"/></svg>';
|
||
}
|
||
|
||
if ( 'facebook' === $network ) {
|
||
return '<svg class="social-icon social-icon-facebook" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="2.5" y="2.5" width="19" height="19" rx="4.5" fill="#1877f2"/><path fill="#fff" d="M13.45 21.5v-7.35h2.48l.37-2.88h-2.85V9.43c0-.83.23-1.4 1.43-1.4h1.52V5.46c-.26-.04-1.17-.12-2.22-.12-2.2 0-3.7 1.34-3.7 3.8v2.13H8v2.88h2.48v7.35h2.97Z"/></svg>';
|
||
}
|
||
|
||
return '';
|
||
}
|
||
|
||
function azionelab_contact_icon( string $type ): string {
|
||
if ( 'email' === $type ) {
|
||
return '<svg class="contact-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3" y="5" width="18" height="14" rx="2.5" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="m4.5 7 7.5 6 7.5-6" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/></svg>';
|
||
}
|
||
|
||
if ( 'phone' === $type ) {
|
||
return '<svg class="contact-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M8.1 4.2 10 8.6l-2 1.5c1.2 2.4 3.1 4.3 5.6 5.7l1.6-2 4.5 1.9c.4.2.7.6.6 1.1l-.6 3c-.1.6-.7 1-1.3.9C10.5 19.9 4.2 13.6 3.4 5.7c-.1-.6.3-1.2.9-1.3l3-.6c.4-.1.8.1 1 .4Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/></svg>';
|
||
}
|
||
|
||
if ( 'whatsapp' === $type ) {
|
||
return '<svg class="contact-icon contact-icon-whatsapp" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4.5 20.2 5.7 16A8.1 8.1 0 1 1 9 19.2l-4.5 1Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="1.8"/><path d="M9.2 8.4c.2-.4.4-.4.7-.4h.5c.2 0 .4.1.5.4l.7 1.6c.1.3 0 .5-.2.7l-.4.5c.7 1.2 1.6 2.1 2.9 2.8l.6-.7c.2-.2.4-.3.7-.2l1.6.8c.3.1.4.3.4.6v.5c0 .4-.2.7-.6.9-.5.3-1.3.4-2.3.1-2.8-.8-5.3-3.2-6.1-6.1-.3-1-.1-1.8.4-2.1Z" fill="currentColor"/></svg>';
|
||
}
|
||
|
||
if ( 'address' === $type ) {
|
||
return '<svg class="contact-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 21s6.2-5.5 6.2-11.1A6.2 6.2 0 0 0 5.8 9.9C5.8 15.5 12 21 12 21Z" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="1.8"/><circle cx="12" cy="9.9" r="2.2" fill="none" stroke="currentColor" stroke-width="1.8"/></svg>';
|
||
}
|
||
|
||
return '';
|
||
}
|
||
|
||
function azionelab_setup(): void {
|
||
load_theme_textdomain( 'azionelab', get_template_directory() . '/languages' );
|
||
add_theme_support( 'title-tag' );
|
||
add_theme_support( 'post-thumbnails' );
|
||
add_theme_support( 'responsive-embeds' );
|
||
add_theme_support(
|
||
'html5',
|
||
array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' )
|
||
);
|
||
}
|
||
add_action( 'after_setup_theme', 'azionelab_setup' );
|
||
|
||
function azionelab_assets(): void {
|
||
wp_enqueue_style( 'azionelab', get_stylesheet_uri(), array(), '1.0.0' );
|
||
}
|
||
add_action( 'wp_enqueue_scripts', 'azionelab_assets' );
|
||
|
||
function azionelab_customize_register( WP_Customize_Manager $customizer ): void {
|
||
$defaults = azionelab_defaults();
|
||
$sections = array(
|
||
'azionelab_hero' => array( 'Hero', 30 ),
|
||
'azionelab_intro' => array( 'Manifesto e laboratorio', 31 ),
|
||
'azionelab_teacher' => array( 'Il maestro', 32 ),
|
||
'azionelab_lessons' => array( 'Le lezioni', 33 ),
|
||
'azionelab_contacts' => array( 'Contatti e footer', 34 ),
|
||
);
|
||
|
||
foreach ( $sections as $id => $section ) {
|
||
$customizer->add_section(
|
||
$id,
|
||
array( 'title' => $section[0], 'priority' => $section[1] )
|
||
);
|
||
}
|
||
|
||
$fields = array(
|
||
'hero_title' => array( 'azionelab_hero', 'Titolo', 'text' ),
|
||
'hero_subtitle' => array( 'azionelab_hero', 'Sottotitolo', 'textarea' ),
|
||
'hero_image' => array( 'azionelab_hero', 'Immagine principale', 'image' ),
|
||
'hero_primary_label' => array( 'azionelab_hero', 'Etichetta CTA primaria', 'text' ),
|
||
'hero_secondary_label' => array( 'azionelab_hero', 'Etichetta CTA secondaria', 'text' ),
|
||
'intro_title' => array( 'azionelab_intro', 'Titolo manifesto', 'text' ),
|
||
'intro_body' => array( 'azionelab_intro', 'Testo manifesto', 'textarea_html' ),
|
||
'laboratory_title' => array( 'azionelab_intro', 'Titolo laboratorio', 'text' ),
|
||
'laboratory_body' => array( 'azionelab_intro', 'Descrizione laboratorio', 'textarea_html' ),
|
||
'laboratory_image' => array( 'azionelab_intro', 'Immagine laboratorio', 'image' ),
|
||
'teacher_name' => array( 'azionelab_teacher', 'Nome', 'text' ),
|
||
'teacher_bio' => array( 'azionelab_teacher', 'Biografia', 'textarea_html' ),
|
||
'teacher_quote' => array( 'azionelab_teacher', 'Citazione', 'textarea' ),
|
||
'teacher_image' => array( 'azionelab_teacher', 'Foto', 'image' ),
|
||
'lesson_schedule' => array( 'azionelab_lessons', 'Quando', 'text' ),
|
||
'lesson_location' => array( 'azionelab_lessons', 'Dove', 'text' ),
|
||
'lesson_audience' => array( 'azionelab_lessons', 'Per chi', 'text' ),
|
||
'lesson_description' => array( 'azionelab_lessons', 'Cosa si fa', 'textarea_html' ),
|
||
'trial_lesson' => array( 'azionelab_lessons', 'Lezione di prova', 'text' ),
|
||
'lesson_notes' => array( 'azionelab_lessons', 'Note', 'textarea' ),
|
||
'contact_email' => array( 'azionelab_contacts', 'Email', 'email' ),
|
||
'contact_phone' => array( 'azionelab_contacts', 'Telefono', 'text' ),
|
||
'contact_whatsapp' => array( 'azionelab_contacts', 'WhatsApp', 'text' ),
|
||
'contact_instagram' => array( 'azionelab_contacts', 'Instagram', 'url' ),
|
||
'contact_facebook' => array( 'azionelab_contacts', 'Facebook', 'url' ),
|
||
'contact_address' => array( 'azionelab_contacts', 'Indirizzo', 'text' ),
|
||
'footer_text' => array( 'azionelab_contacts', 'Testo footer', 'text' ),
|
||
);
|
||
|
||
foreach ( $fields as $id => $field ) {
|
||
$type = $field[2];
|
||
$sanitize_callback = 'sanitize_text_field';
|
||
if ( 'textarea' === $type ) {
|
||
$sanitize_callback = 'sanitize_textarea_field';
|
||
} elseif ( 'textarea_html' === $type ) {
|
||
$sanitize_callback = 'wp_kses_post';
|
||
} elseif ( 'email' === $type ) {
|
||
$sanitize_callback = 'sanitize_email';
|
||
} elseif ( 'url' === $type || 'image' === $type ) {
|
||
$sanitize_callback = 'esc_url_raw';
|
||
}
|
||
|
||
$customizer->add_setting(
|
||
$id,
|
||
array(
|
||
'default' => $defaults[ $id ] ?? '',
|
||
'sanitize_callback' => $sanitize_callback,
|
||
)
|
||
);
|
||
|
||
if ( 'image' === $type ) {
|
||
$customizer->add_control(
|
||
new WP_Customize_Image_Control(
|
||
$customizer,
|
||
$id,
|
||
array( 'label' => $field[1], 'section' => $field[0] )
|
||
)
|
||
);
|
||
} else {
|
||
$customizer->add_control(
|
||
$id,
|
||
array(
|
||
'label' => $field[1],
|
||
'section' => $field[0],
|
||
'type' => str_starts_with( $type, 'textarea' ) ? 'textarea' : $type,
|
||
)
|
||
);
|
||
}
|
||
}
|
||
}
|
||
add_action( 'customize_register', 'azionelab_customize_register' );
|