feat: preparar migración del evangelio diario (issue #20)

This commit is contained in:
2026-08-30 08:44:10 -04:00
parent 3da7c79f5a
commit 67857638ba
2 changed files with 113 additions and 9 deletions
+31 -9
View File
@@ -1204,8 +1204,9 @@ add_shortcode('fea_evangelio', function($atts) {
// "El Evangelio de cada día": dos devocionales diarios indexados por día del año.
// · A la fuente cada día (texto, Fray Marcos) → categoría term_id 14
// · Otro evangelio es posible (vídeo YouTube) → categoría term_id 15
// Los posts están titulados "D mes" (ej. "21 junio"). Se muestra el de HOY
// (zona horaria del sitio) o el día indicado por ?fed=M-D, con pestañas para
// El texto de Fray Marcos se resuelve contra el calendario litúrgico versionado
// (fecha ISO -> book_index), no por el título civil heredado de Joomla. Se muestra
// el de HOY (zona horaria del sitio) o el día indicado por ?fed=M-D, con pestañas para
// que el usuario elija formato y navegación día anterior / siguiente.
// Contenido solo en ES (devocional sin traducción) → categorías 14/15 fijas.
add_shortcode('fea_evangelio_diario', function($atts) {
@@ -1220,23 +1221,44 @@ add_shortcode('fea_evangelio_diario', function($atts) {
$gm = (int) $mm[1]; $gd = (int) $mm[2];
if ($gm >= 1 && $gm <= 12 && $gd >= 1 && $gd <= 31) { $m = $gm; $d = $gd; }
}
$titulo_dia = $d . ' ' . $MESES[$m]; // "21 junio"
$date = $now->setDate((int) $now->format('Y'), $m, $d);
$calendar_path = defined('FEA_EVANGELIO_CALENDAR_PATH')
? FEA_EVANGELIO_CALENDAR_PATH
: WP_CONTENT_DIR . '/fea-data/calendario-liturgico-2026-2040.json';
$calendar = is_readable($calendar_path)
? json_decode((string) file_get_contents($calendar_path), true)
: null;
$book_index = (int) ($calendar['dates'][$date->format('Y-m-d')]['book_index'] ?? 0);
$find = function($cat) use ($titulo_dia) {
$find_text = function($index) {
global $wpdb;
if ($index < 1) return null;
$id = $wpdb->get_var($wpdb->prepare(
"SELECT p.ID FROM {$wpdb->posts} p
JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID
WHERE pm.meta_key = '_fea_book_index' AND pm.meta_value = %d
AND p.post_type = 'post' AND p.post_status = 'publish'
ORDER BY p.ID ASC LIMIT 1",
$index));
return $id ? get_post((int) $id) : null;
};
$texto = $find_text($book_index);
// El vídeo queda deliberadamente con el índice civil heredado: su catálogo
// no forma parte de la migración litúrgica de #20.
$titulo_dia = $d . ' ' . $MESES[$m];
$find_video = function() use ($titulo_dia) {
global $wpdb;
$id = $wpdb->get_var($wpdb->prepare(
"SELECT p.ID FROM {$wpdb->posts} p
JOIN {$wpdb->term_relationships} tr ON tr.object_id = p.ID
JOIN {$wpdb->term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tt.taxonomy = 'category' AND tt.term_id = %d
WHERE tt.taxonomy = 'category' AND tt.term_id = 15
AND p.post_type = 'post' AND p.post_status = 'publish'
AND LOWER(TRIM(p.post_title)) = %s
ORDER BY p.ID ASC LIMIT 1",
$cat, $titulo_dia));
ORDER BY p.ID ASC LIMIT 1", $titulo_dia));
return $id ? get_post((int) $id) : null;
};
$texto = $find(14);
$video = $find(15);
$video = $find_video();
// navegación por día del calendario (año irrelevante; usamos un año bisiesto fijo)
$base = get_permalink();