184 lines
6.7 KiB
PHP
184 lines
6.7 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* Template: Item de Evento
|
||
|
|
*
|
||
|
|
* Variables disponibles:
|
||
|
|
* - $id, $title, $excerpt, $content, $permalink, $thumbnail
|
||
|
|
* - $iniciativas, $lineas, $widget, $type, $date
|
||
|
|
* - $fecha_inicio, $hora_inicio, $fecha_fin, $hora_fin
|
||
|
|
* - $lugar, $direccion, $url_online, $url_inscripcion, $tipos_evento
|
||
|
|
*
|
||
|
|
* @package Bloques_Transicion
|
||
|
|
*/
|
||
|
|
|
||
|
|
if (!defined('ABSPATH')) {
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Determinar si es online, presencial o híbrido
|
||
|
|
$es_online = false;
|
||
|
|
$es_presencial = false;
|
||
|
|
if (!empty($tipos_evento)) {
|
||
|
|
foreach ($tipos_evento as $tipo) {
|
||
|
|
if ($tipo->slug === 'online') $es_online = true;
|
||
|
|
if ($tipo->slug === 'presencial') $es_presencial = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$modalidad = '';
|
||
|
|
$modalidad_class = '';
|
||
|
|
if ($es_online && $es_presencial) {
|
||
|
|
$modalidad = __('Híbrido', 'bloques-transicion');
|
||
|
|
$modalidad_class = 'bloques-modalidad-hibrido';
|
||
|
|
} elseif ($es_online) {
|
||
|
|
$modalidad = __('Online', 'bloques-transicion');
|
||
|
|
$modalidad_class = 'bloques-modalidad-online';
|
||
|
|
} elseif ($es_presencial) {
|
||
|
|
$modalidad = __('Presencial', 'bloques-transicion');
|
||
|
|
$modalidad_class = 'bloques-modalidad-presencial';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Meses en español abreviados
|
||
|
|
$meses = [
|
||
|
|
'01' => 'ENE', '02' => 'FEB', '03' => 'MAR', '04' => 'ABR',
|
||
|
|
'05' => 'MAY', '06' => 'JUN', '07' => 'JUL', '08' => 'AGO',
|
||
|
|
'09' => 'SEP', '10' => 'OCT', '11' => 'NOV', '12' => 'DIC',
|
||
|
|
];
|
||
|
|
|
||
|
|
// Parsear fecha
|
||
|
|
$dia = '';
|
||
|
|
$mes = '';
|
||
|
|
if ($fecha_inicio) {
|
||
|
|
$fecha_clean = str_replace('-', '', $fecha_inicio);
|
||
|
|
if (strlen($fecha_clean) >= 8) {
|
||
|
|
$dia = ltrim(substr($fecha_clean, 6, 2), '0');
|
||
|
|
$mes_num = substr($fecha_clean, 4, 2);
|
||
|
|
$mes = $meses[$mes_num] ?? $mes_num;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Determinar ubicación a mostrar
|
||
|
|
$ubicacion_texto = $modalidad ?: $lugar;
|
||
|
|
|
||
|
|
// Widget "agenda" (para bloques-agenda)
|
||
|
|
if ($widget === 'agenda'): ?>
|
||
|
|
<article id="bloques-evento-<?php echo esc_attr($id); ?>" class="bloques-agenda-item">
|
||
|
|
<div class="bloques-agenda-fecha">
|
||
|
|
<span class="bloques-agenda-mes"><?php echo esc_html($mes); ?></span>
|
||
|
|
<span class="bloques-agenda-dia"><?php echo esc_html($dia); ?></span>
|
||
|
|
</div>
|
||
|
|
<div class="bloques-agenda-content">
|
||
|
|
<div class="bloques-agenda-meta">
|
||
|
|
<?php if ($hora_inicio): ?>
|
||
|
|
<span class="bloques-agenda-hora"><?php echo esc_html($hora_inicio); ?></span>
|
||
|
|
<?php endif; ?>
|
||
|
|
<?php if ($ubicacion_texto): ?>
|
||
|
|
<span class="bloques-agenda-separator">•</span>
|
||
|
|
<span class="bloques-agenda-ubicacion <?php echo esc_attr($modalidad_class); ?>">
|
||
|
|
<?php echo esc_html($ubicacion_texto); ?>
|
||
|
|
</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
<h4 class="bloques-agenda-title"><?php echo esc_html($title); ?></h4>
|
||
|
|
</div>
|
||
|
|
</article>
|
||
|
|
|
||
|
|
<?php else:
|
||
|
|
// Widget por defecto (list o grid)
|
||
|
|
$classes = ['bloques-item', 'bloques-item-evento'];
|
||
|
|
if ($widget === 'list') {
|
||
|
|
$classes[] = 'bloques-item-list';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Formatear fecha completa
|
||
|
|
$fecha_formateada = '';
|
||
|
|
if ($fecha_inicio) {
|
||
|
|
$fecha_obj = DateTime::createFromFormat('Ymd', str_replace('-', '', $fecha_inicio));
|
||
|
|
if ($fecha_obj) {
|
||
|
|
$meses_largo = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
|
||
|
|
$dia_num = $fecha_obj->format('j');
|
||
|
|
$mes_nombre = $meses_largo[(int)$fecha_obj->format('n') - 1];
|
||
|
|
$anio = $fecha_obj->format('Y');
|
||
|
|
$fecha_formateada = "$dia_num de $mes_nombre, $anio";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<article id="bloques-evento-<?php echo esc_attr($id); ?>" class="<?php echo esc_attr(implode(' ', $classes)); ?>">
|
||
|
|
<div class="bloques-evento-fecha">
|
||
|
|
<span class="bloques-evento-dia"><?php echo esc_html($dia); ?></span>
|
||
|
|
<span class="bloques-evento-mes"><?php echo esc_html($mes); ?></span>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="bloques-item-content">
|
||
|
|
<header class="bloques-item-header">
|
||
|
|
<?php if ($modalidad): ?>
|
||
|
|
<span class="bloques-evento-modalidad <?php echo esc_attr($modalidad_class); ?>">
|
||
|
|
<?php echo esc_html($modalidad); ?>
|
||
|
|
</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<h3 class="bloques-item-title">
|
||
|
|
<a href="<?php echo esc_url($permalink); ?>">
|
||
|
|
<?php echo esc_html($title); ?>
|
||
|
|
</a>
|
||
|
|
</h3>
|
||
|
|
</header>
|
||
|
|
|
||
|
|
<div class="bloques-evento-meta">
|
||
|
|
<?php if ($fecha_formateada): ?>
|
||
|
|
<div class="bloques-evento-meta-item">
|
||
|
|
<span class="bloques-icon bloques-icon-calendar"></span>
|
||
|
|
<span><?php echo esc_html($fecha_formateada); ?></span>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<?php if ($hora_inicio): ?>
|
||
|
|
<div class="bloques-evento-meta-item">
|
||
|
|
<span class="bloques-icon bloques-icon-clock"></span>
|
||
|
|
<span>
|
||
|
|
<?php echo esc_html($hora_inicio); ?>
|
||
|
|
<?php if ($hora_fin): ?>
|
||
|
|
- <?php echo esc_html($hora_fin); ?>
|
||
|
|
<?php endif; ?>
|
||
|
|
</span>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<?php if ($lugar || $direccion): ?>
|
||
|
|
<div class="bloques-evento-meta-item">
|
||
|
|
<span class="bloques-icon bloques-icon-location"></span>
|
||
|
|
<span><?php echo esc_html($lugar ?: $direccion); ?></span>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php if ($excerpt): ?>
|
||
|
|
<div class="bloques-item-excerpt">
|
||
|
|
<?php echo wp_kses_post($excerpt); ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<?php if (!empty($iniciativas)): ?>
|
||
|
|
<div class="bloques-item-taxonomies">
|
||
|
|
<?php foreach ($iniciativas as $term):
|
||
|
|
$color = get_field('color', $term);
|
||
|
|
?>
|
||
|
|
<span class="bloques-tag bloques-tag-iniciativa" style="<?php echo $color ? '--tag-color: ' . esc_attr($color) . ';' : ''; ?>">
|
||
|
|
<?php echo esc_html($term->name); ?>
|
||
|
|
</span>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<footer class="bloques-item-footer">
|
||
|
|
<a href="<?php echo esc_url($permalink); ?>" class="bloques-item-link bloques-btn">
|
||
|
|
<?php _e('Ver evento', 'bloques-transicion'); ?>
|
||
|
|
</a>
|
||
|
|
<?php if ($url_inscripcion): ?>
|
||
|
|
<a href="<?php echo esc_url($url_inscripcion); ?>" class="bloques-btn bloques-btn-secondary" target="_blank" rel="noopener">
|
||
|
|
<?php _e('Inscribirse', 'bloques-transicion'); ?>
|
||
|
|
</a>
|
||
|
|
<?php endif; ?>
|
||
|
|
</footer>
|
||
|
|
</div>
|
||
|
|
</article>
|
||
|
|
<?php endif; ?>
|