Handoff carta 46956: traducciones Haiku + evangelios descargados + scripts; despliegue prod pendiente (issue #88, #87)

This commit is contained in:
rafa
2026-06-17 21:40:56 -04:00
parent 27aad22cd5
commit 6791afdb42
8 changed files with 589 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
require '/var/www/html/wp-load.php';
$ES = 2682; // MATEO 10, 26-33 (es)
$src = get_post($ES);
$tr_html = json_decode(file_get_contents('/tmp/lecturas_mateo.json'), true);
$BOOK = ['en'=>'MATTHEW','fr'=>'MATTHIEU','it'=>'MATTEO','pt'=>'MATEUS'];
$VER = ['en'=>'Douay-Rheims Bible','fr'=>'Bible du Semeur 2015','it'=>'Nuova Riveduta 2006','pt'=>'Bíblia CNBB 2002'];
$REST = 'MATEO 10, 26-33'; // título es
$tail = preg_replace('~^MATEO~','',$REST); // " 10, 26-33"
$es_cats = wp_get_post_categories($ES);
$grp = pll_get_post_translations($ES); if(!$grp) $grp=['es'=>$ES];
foreach (['en','fr','it','pt'] as $lang) {
$exist = (int)pll_get_post($ES,$lang);
if ($exist && get_post($exist)) { echo "$lang ya existe #$exist — saltado\n"; $grp[$lang]=$exist; continue; }
$title = $BOOK[$lang].$tail;
$id = wp_insert_post([
'post_title'=>$title,'post_content'=>$tr_html[$lang],'post_status'=>'publish',
'post_type'=>'post','post_author'=>(int)$src->post_author,'post_date'=>$src->post_date,
], true);
if (is_wp_error($id)) { echo "$lang ERROR ".$id->get_error_message()."\n"; continue; }
pll_set_post_language($id,$lang);
$mapped=[]; foreach($es_cats as $c){ $tc=(int)pll_get_term($c,$lang); $mapped[]=$tc?:$c; }
wp_set_post_categories($id, array_values(array_unique($mapped)));
$grp[$lang]=$id; pll_save_post_translations($grp);
update_post_meta($id,'lectura_fuente',$VER[$lang]);
update_post_meta($id,'traduccion_origen',$ES);
echo "$lang creado #$id «$title» [".$VER[$lang]."]\n";
}
echo "Grupo final: ".json_encode(pll_get_post_translations($ES))."\n";