feat(portada): modelo carta→portada + slider sync desde filesystem

- fea-carta-portada.php (nuevo, 1.0): parser de la carta semanal.
  Extrae secciones (Evangelio, Artículos, Eucaristía, Multimedia, EFFA)
  por encabezados y resuelve los href (WP slug o K2 legacy id) a
  wp_posts.ID. Cache en transient 15 min, invalidación en save_post.
  Cierra issue #38.

- fea-homepage.php: 4 shortcodes reescritos para usar
  fea_carta_section_posts() como fuente primaria, manteniendo el
  fallback existente (ACF + últimos por categoría).
  Afecta: [fea_articulos_semana], [fea_evangelio], [fea_eucaristia],
  [fea_multimedia]. El hero y noticia_centro sin cambios.

- fea-slider-sync.php (nuevo, 1.0): sincroniza Smart Slider 3 id 2
  con uploads/home/. Editor sube/borra imágenes en esa carpeta y el
  slider se actualiza automáticamente al primer pageview (modelo
  paridad con Joomla mod_ariimageslider). Cierra issue #43.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 12:26:01 -04:00
parent 56ee1580b0
commit 382a6a6e87
3 changed files with 501 additions and 31 deletions
+132 -31
View File
@@ -437,6 +437,56 @@ add_action('wp_head', function() {
echo '<style>.wp-block-post-title { display:none !important; }</style>';
}, 20);
// ── H1 semántico oculto para páginas sin título visible ───────────────────
add_action('wp_head', function() {
?>
<style>
.fea-sr-only {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
clip-path: inset(50%) !important;
white-space: nowrap !important;
border: 0 !important;
}
</style>
<?php
}, 20);
add_filter('the_content', function($content) {
if (is_admin() || !is_main_query() || !in_the_loop()) return $content;
if (preg_match('/<h1\b/i', $content)) return $content;
$title = '';
if (fea_is_front_page()) {
$title = get_bloginfo('name') ?: 'Fe Adulta';
} elseif (fea_is_escuela_page()) {
$title = 'Escuela de Formación en Fe Adulta';
}
if (!$title) return $content;
return '<h1 class="fea-sr-only fea-page-h1">' . esc_html($title) . '</h1>' . $content;
}, 5);
// ── Ocultar metadatos de post en páginas estáticas ────────────────────────
add_action('wp_head', function() {
if (!fea_hide_static_meta()) return;
?>
<style>
.wp-block-group:has(> .wp-block-avatar):has(.wp-block-post-author-name),
.wp-block-post-author-name,
.wp-block-post-terms.taxonomy-category {
display: none !important;
}
</style>
<?php
}, 20);
// ── Byline personalizado en artículos individuales ────────────────────────
// ── Byline personalizado: se gestiona desde el template FSE (ID 42359) ────
@@ -518,6 +568,41 @@ function fea_is_front_page(): bool {
return $id && in_array($id, fea_front_page_ids(), true);
}
/** True para la landing de Escuela, que no muestra título visible. */
function fea_is_escuela_page(): bool {
if (!is_page()) return false;
$page = get_queried_object();
return $page instanceof WP_Post && $page->post_name === 'escuela';
}
/** True para contenidos importados que funcionan como páginas institucionales. */
function fea_hide_static_meta(): bool {
if (is_admin() || fea_is_front_page()) return false;
$post = get_queried_object();
if (!$post instanceof WP_Post) return false;
if ($post->post_type === 'page') return true;
$slugs = [
'colaboradores',
'contactar',
'multimedia',
'ayuda',
'video-tutorial',
'como-usar-el-buscador-avanzado',
'portal',
'paraponeraldialafe',
'alta',
'alta-en-effa',
'regala',
'catalogo-de-publicaciones-2018',
'nueva-politica-de-privacidad',
];
return in_array($post->post_name, $slugs, true);
}
/** Devuelve el idioma actual de Polylang, o 'es' si no está activo. */
function fea_current_lang(): string {
return (function_exists('pll_current_language') ? pll_current_language() : null) ?: 'es';
@@ -625,22 +710,26 @@ add_shortcode('fea_carta_semana_hero', function() {
});
// ── Shortcode: [fea_articulos_semana] ─────────────────────────────────────
// Fuente principal: links de la sección "Artículos seleccionados" de la carta vigente.
// Fallbacks: ACF portada_articulos → últimos por categoría.
add_shortcode('fea_articulos_semana', function($atts) {
$lang = fea_current_lang();
$labels = fea_labels();
$atts = shortcode_atts(['titulo' => $labels['articulos']], $atts);
$page = fea_front_page_id();
// Selección editorial ACF (solo para ES; otros idiomas usan fallback)
$posts = [];
if ($lang === 'es' && function_exists('get_field')) {
// 1) Fuente principal: sección "Artículos seleccionados" de la carta vigente
$posts = function_exists('fea_carta_section_posts') ? fea_carta_section_posts('articulos', $lang) : [];
// 2) Fallback ACF (solo ES)
if (empty($posts) && $lang === 'es' && function_exists('get_field')) {
$seleccion = get_field('portada_articulos', $page) ?: [];
foreach ($seleccion as $p) {
if ($p->post_status === 'publish') $posts[] = $p;
}
}
// Fallback: últimos artículos en el idioma actual
// 3) Fallback: últimos artículos en el idioma actual
if (empty($posts)) {
$posts = get_posts([
'posts_per_page' => 9,
@@ -661,30 +750,33 @@ add_shortcode('fea_articulos_semana', function($atts) {
});
// ── Shortcode: [fea_evangelio] ────────────────────────────────────────────
// Editorial (cat 1646) primero, luego comentarios (cat 1647). Máx 7 en total.
// Fuente principal: sección "Evangelio y comentarios" de la carta vigente.
// Fallback: editorial cat 1646 + comentarios cat 1647 por fecha.
add_shortcode('fea_evangelio', function($atts) {
$lang = fea_current_lang();
$labels = fea_labels();
$atts = shortcode_atts(['titulo' => $labels['evangelio']], $atts);
$editorial = get_posts([
'posts_per_page' => 1,
'category__in' => [fea_cat(1646)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
$posts = function_exists('fea_carta_section_posts') ? fea_carta_section_posts('evangelio', $lang) : [];
$comentarios = get_posts([
'posts_per_page' => 6,
'category__in' => [fea_cat(1647)],
'category__not_in' => [fea_cat(1646)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
$posts = array_merge($editorial, $comentarios);
if (empty($posts)) {
$editorial = get_posts([
'posts_per_page' => 1,
'category__in' => [fea_cat(1646)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
$comentarios = get_posts([
'posts_per_page' => 6,
'category__in' => [fea_cat(1647)],
'category__not_in' => [fea_cat(1646)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
$posts = array_merge($editorial, $comentarios);
}
if (!$posts) return '';
$html = '<section class="fea-section">'
@@ -695,18 +787,24 @@ add_shortcode('fea_evangelio', function($atts) {
});
// ── Shortcode: [fea_eucaristia] ───────────────────────────────────────────
// Fuente principal: sección "Para unas eucaristías más participativas" de la carta.
// Fallback: cat 1648 por fecha.
add_shortcode('fea_eucaristia', function($atts) {
$lang = fea_current_lang();
$labels = fea_labels();
$atts = shortcode_atts(['titulo' => $labels['eucaristia']], $atts);
$posts = get_posts([
'posts_per_page' => 6,
'category__in' => [fea_cat(1648)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
$posts = function_exists('fea_carta_section_posts') ? fea_carta_section_posts('eucaristia', $lang) : [];
if (empty($posts)) {
$posts = get_posts([
'posts_per_page' => 6,
'category__in' => [fea_cat(1648)],
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
]);
}
if (!$posts) return '';
$html = '<section class="fea-section">'
@@ -717,14 +815,17 @@ add_shortcode('fea_eucaristia', function($atts) {
});
// ── Shortcode: [fea_multimedia] ───────────────────────────────────────────
// Fuente principal: sección "Material multimedia" de la carta vigente.
// Fallbacks: ACF portada_multimedia → últimos por categoría.
add_shortcode('fea_multimedia', function($atts) {
$lang = fea_current_lang();
$labels = fea_labels();
$atts = shortcode_atts(['titulo' => $labels['multimedia']], $atts);
$page = fea_front_page_id();
$posts = [];
if ($lang === 'es' && function_exists('get_field')) {
$posts = function_exists('fea_carta_section_posts') ? fea_carta_section_posts('multimedia', $lang) : [];
if (empty($posts) && $lang === 'es' && function_exists('get_field')) {
$seleccion = get_field('portada_multimedia', $page) ?: [];
foreach ($seleccion as $p) {
if ($p->post_status === 'publish') $posts[] = $p;