Plugins bloques
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/**
|
||||
* Template: Item de Actuación
|
||||
*
|
||||
* Variables disponibles:
|
||||
* - $id, $title, $excerpt, $content, $permalink, $thumbnail
|
||||
* - $iniciativas, $lineas, $widget, $type
|
||||
* - $es_piloto, $direccion, $localidad, $latitud, $longitud
|
||||
*
|
||||
* @package Bloques_Transicion
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$classes = ['bloques-item', 'bloques-item-actuacion'];
|
||||
if ($widget === 'list') {
|
||||
$classes[] = 'bloques-item-list';
|
||||
}
|
||||
if ($es_piloto) {
|
||||
$classes[] = 'bloques-item-piloto';
|
||||
}
|
||||
?>
|
||||
<article id="bloques-actuacion-<?php echo esc_attr($id); ?>" class="<?php echo esc_attr(implode(' ', $classes)); ?>">
|
||||
<?php if ($thumbnail): ?>
|
||||
<div class="bloques-item-thumbnail">
|
||||
<a href="<?php echo esc_url($permalink); ?>">
|
||||
<img src="<?php echo esc_url($thumbnail); ?>" alt="<?php echo esc_attr($thumbnail_alt ?: $title); ?>" loading="lazy">
|
||||
</a>
|
||||
<?php if ($es_piloto): ?>
|
||||
<span class="bloques-badge bloques-badge-piloto">
|
||||
<?php _e('Piloto', 'bloques-transicion'); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="bloques-item-content">
|
||||
<header class="bloques-item-header">
|
||||
<?php if (!empty($iniciativas)): ?>
|
||||
<div class="bloques-item-taxonomies">
|
||||
<?php foreach ($iniciativas as $term):
|
||||
$color = get_field('color', $term);
|
||||
$icono = get_field('icono', $term);
|
||||
?>
|
||||
<span class="bloques-tag bloques-tag-iniciativa" style="<?php echo $color ? '--tag-color: ' . esc_attr($color) . ';' : ''; ?>">
|
||||
<?php if ($icono): ?>
|
||||
<img src="<?php echo esc_url($icono); ?>" alt="" class="bloques-tag-icon">
|
||||
<?php endif; ?>
|
||||
<?php echo esc_html($term->name); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 class="bloques-item-title">
|
||||
<a href="<?php echo esc_url($permalink); ?>">
|
||||
<?php echo esc_html($title); ?>
|
||||
</a>
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
<?php if ($excerpt): ?>
|
||||
<div class="bloques-item-excerpt">
|
||||
<?php echo wp_kses_post($excerpt); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($localidad || $direccion): ?>
|
||||
<div class="bloques-item-location">
|
||||
<span class="bloques-icon bloques-icon-location"></span>
|
||||
<?php
|
||||
$location_parts = array_filter([$direccion, $localidad]);
|
||||
echo esc_html(implode(', ', $location_parts));
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($lineas)): ?>
|
||||
<div class="bloques-item-lineas">
|
||||
<?php foreach ($lineas as $term):
|
||||
$icono = get_field('icono', $term);
|
||||
?>
|
||||
<span class="bloques-linea-badge" title="<?php echo esc_attr($term->name); ?>">
|
||||
<?php if ($icono): ?>
|
||||
<img src="<?php echo esc_url($icono); ?>" alt="<?php echo esc_attr($term->name); ?>">
|
||||
<?php else: ?>
|
||||
<?php echo esc_html(mb_substr($term->name, 0, 1)); ?>
|
||||
<?php endif; ?>
|
||||
</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 actuación', 'bloques-transicion'); ?>
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
</article>
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Template: Item por defecto para listados
|
||||
*
|
||||
* Variables disponibles:
|
||||
* - $id, $title, $excerpt, $content, $permalink, $thumbnail
|
||||
* - $iniciativas, $lineas, $widget, $type
|
||||
*
|
||||
* @package Bloques_Transicion
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$classes = ['bloques-item', 'bloques-item-' . $type];
|
||||
if ($widget === 'list') {
|
||||
$classes[] = 'bloques-item-list';
|
||||
}
|
||||
?>
|
||||
<article id="bloques-item-<?php echo esc_attr($id); ?>" class="<?php echo esc_attr(implode(' ', $classes)); ?>">
|
||||
<?php if ($thumbnail): ?>
|
||||
<div class="bloques-item-thumbnail">
|
||||
<a href="<?php echo esc_url($permalink); ?>">
|
||||
<img src="<?php echo esc_url($thumbnail); ?>" alt="<?php echo esc_attr($thumbnail_alt ?: $title); ?>" loading="lazy">
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="bloques-item-content">
|
||||
<header class="bloques-item-header">
|
||||
<?php if (!empty($iniciativas) || !empty($lineas)): ?>
|
||||
<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; ?>
|
||||
|
||||
<?php foreach ($lineas as $term):
|
||||
$color = get_field('color', $term);
|
||||
?>
|
||||
<span class="bloques-tag bloques-tag-linea" style="<?php echo $color ? '--tag-color: ' . esc_attr($color) . ';' : ''; ?>">
|
||||
<?php echo esc_html($term->name); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 class="bloques-item-title">
|
||||
<a href="<?php echo esc_url($permalink); ?>">
|
||||
<?php echo esc_html($title); ?>
|
||||
</a>
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
<?php if ($excerpt): ?>
|
||||
<div class="bloques-item-excerpt">
|
||||
<?php echo wp_kses_post($excerpt); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<footer class="bloques-item-footer">
|
||||
<a href="<?php echo esc_url($permalink); ?>" class="bloques-item-link">
|
||||
<?php _e('Ver más', 'bloques-transicion'); ?>
|
||||
<span class="bloques-arrow">→</span>
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
</article>
|
||||
@@ -0,0 +1,184 @@
|
||||
<?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; ?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Template: Item de Noticia
|
||||
*
|
||||
* Variables disponibles:
|
||||
* - $id, $title, $excerpt, $content, $permalink, $thumbnail
|
||||
* - $widget, $type, $date
|
||||
* - $category, $category_color
|
||||
*
|
||||
* @package Bloques_Transicion
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Widget compact (para bloques-novedades)
|
||||
if ($widget === 'compact'): ?>
|
||||
<article id="bloques-noticia-<?php echo esc_attr($id); ?>" class="bloques-novedad-item">
|
||||
<div class="bloques-novedad-content">
|
||||
<div class="bloques-novedad-meta">
|
||||
<?php if ($category): ?>
|
||||
<span class="bloques-novedad-category" style="background-color: <?php echo esc_attr($category_color); ?>;">
|
||||
<?php echo esc_html($category->name); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<span class="bloques-novedad-date"><?php echo esc_html($date); ?></span>
|
||||
</div>
|
||||
<h4 class="bloques-novedad-title">
|
||||
<a href="<?php echo esc_url($permalink); ?>">
|
||||
<?php echo esc_html($title); ?>
|
||||
</a>
|
||||
</h4>
|
||||
<p class="bloques-novedad-excerpt">
|
||||
<?php echo wp_trim_words($excerpt, 15, '...'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
<?php else:
|
||||
// Widget grid (card completa)
|
||||
$classes = ['bloques-card', 'bloques-card-noticia'];
|
||||
if ($widget === 'list') {
|
||||
$classes[] = 'bloques-card-horizontal';
|
||||
}
|
||||
?>
|
||||
<article id="bloques-noticia-<?php echo esc_attr($id); ?>" class="<?php echo esc_attr(implode(' ', $classes)); ?>">
|
||||
<a href="<?php echo esc_url($permalink); ?>" class="bloques-card-link">
|
||||
<div class="bloques-card-thumbnail">
|
||||
<?php if ($thumbnail): ?>
|
||||
<img src="<?php echo esc_url($thumbnail); ?>" alt="<?php echo esc_attr($thumbnail_alt ?: $title); ?>" loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="bloques-card-placeholder">
|
||||
<span class="bloques-card-placeholder-text">BLOQUES</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($category): ?>
|
||||
<span class="bloques-card-badge" style="background-color: <?php echo esc_attr($category_color); ?>;">
|
||||
<?php echo esc_html($category->name); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="bloques-card-content">
|
||||
<h3 class="bloques-card-title"><?php echo esc_html($title); ?></h3>
|
||||
|
||||
<?php if ($excerpt): ?>
|
||||
<p class="bloques-card-excerpt"><?php echo wp_trim_words($excerpt, 20, '...'); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<span class="bloques-card-date"><?php echo esc_html($date); ?></span>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Template: Item de Recurso (Grid Card)
|
||||
*
|
||||
* Variables disponibles:
|
||||
* - $id, $title, $excerpt, $content, $permalink, $thumbnail
|
||||
* - $iniciativas, $lineas, $widget, $type, $date
|
||||
* - $archivo, $tipo_recurso, $url_externa
|
||||
*
|
||||
* @package Bloques_Transicion
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Determinar URL de descarga
|
||||
$download_url = '';
|
||||
$file_info = '';
|
||||
$file_extension = '';
|
||||
$file_size = '';
|
||||
|
||||
if (!empty($archivo) && is_array($archivo)) {
|
||||
$download_url = $archivo['url'];
|
||||
$file_extension = strtoupper(pathinfo($archivo['filename'], PATHINFO_EXTENSION));
|
||||
$file_size = isset($archivo['filesize']) ? size_format($archivo['filesize']) : '';
|
||||
} elseif ($url_externa) {
|
||||
$download_url = $url_externa;
|
||||
$file_extension = 'WEB';
|
||||
}
|
||||
|
||||
// Clases según widget
|
||||
$classes = ['bloques-card', 'bloques-card-recurso'];
|
||||
if ($widget === 'list') {
|
||||
$classes[] = 'bloques-card-horizontal';
|
||||
}
|
||||
?>
|
||||
<article id="bloques-recurso-<?php echo esc_attr($id); ?>" class="<?php echo esc_attr(implode(' ', $classes)); ?>">
|
||||
<div class="bloques-card-thumbnail">
|
||||
<?php if ($thumbnail): ?>
|
||||
<img src="<?php echo esc_url($thumbnail); ?>" alt="<?php echo esc_attr($thumbnail_alt ?: $title); ?>" loading="lazy">
|
||||
<?php else: ?>
|
||||
<div class="bloques-card-placeholder">
|
||||
<span class="bloques-card-placeholder-text">COMMUNITY</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($file_extension): ?>
|
||||
<span class="bloques-card-badge"><?php echo esc_html($file_extension); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="bloques-card-content">
|
||||
<h3 class="bloques-card-title"><?php echo esc_html($title); ?></h3>
|
||||
|
||||
<?php if ($file_size): ?>
|
||||
<span class="bloques-card-meta">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"/>
|
||||
</svg>
|
||||
<?php echo esc_html($file_size); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="bloques-card-footer">
|
||||
<?php if ($download_url): ?>
|
||||
<a href="<?php echo esc_url($download_url); ?>" class="bloques-btn-outline" target="_blank" rel="noopener">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>
|
||||
</svg>
|
||||
<?php _e('Descargar', 'bloques-transicion'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
Reference in New Issue
Block a user