77 lines
2.6 KiB
PHP
77 lines
2.6 KiB
PHP
<?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>
|