Files
feadulta/scripts/homenajes-2026-06/mardones_prod_create_and_repoint.php
rafa 6b61250b0b Sincronizar mu-plugins/ y scripts/ con el estado real del sitio (2026-07-16)
Este repo llevaba desde el 28-jun sin actualizarse (salvo sync_carta_from_prod.py).
Se pone al dia con 3 semanas de trabajo que solo vivian en el checkout local
completo del proyecto:

- Fix del buscador (issue #178): AND obligatorio en FULLTEXT (antes devolvia
  practicamente todo el sitio con cualquier busqueda), exclusion de paginas
  indice residuales de la migracion K2, soporte de frase exacta entre comillas.
- Nuevos mu-plugins ya desplegados a prod: fea-carta-id-api, fea-cloudflare-realip,
  fea-crear-autor-api, fea-gsc-verification, fea-legacy-redirect (cutover
  Joomla->WP, ver issue #162).
- TTS multi-voz por autor, scripts de traduccion, sync de audio a prod,
  homenajes Mardones/Galarreta.

Se mantiene la estructura plana del repo (mu-plugins/ + scripts/, sin el
wordpress/wp-content/ del checkout completo) tal y como documenta el README:
es la convencion establecida para este repo, mas limpia para quien solo
necesita leer el codigo. Anadido .gitignore (cache de Python que no debia
commitearse).

Fuente: checkout local completo del proyecto, rama main (commit 69e849d).
2026-07-15 20:26:43 -04:00

27 lines
1.4 KiB
PHP

<?php
$man=json_decode(file_get_contents('/entrada/manifest_prod.json'),true);
$map=[]; $created=0;$skip=0;
foreach($man as $m){
$ex=get_posts(["meta_key"=>"_mardones_src","meta_value"=>$m['file'],"post_type"=>"post","post_status"=>"any","posts_per_page"=>1,"suppress_filters"=>true]);
if($ex){ $map[$m['file']]=$ex[0]->ID; $skip++; continue; }
$author=(int)$m['author']; if($author && !get_userdata($author)) $author=1;
$id=wp_insert_post(["post_type"=>"post","post_status"=>"publish","post_author"=>$author,
"post_title"=>$m['title'],"post_content"=>$m['content'],"to_ping"=>"","pinged"=>"","post_content_filtered"=>""],true);
if(is_wp_error($id)){ echo "ERR ".$m['file'].": ".$id->get_error_message()."\n"; continue; }
update_post_meta($id,"_mardones_src",$m['file']);
wp_set_post_categories($id,[38]);
if(function_exists('pll_set_post_language')) pll_set_post_language($id,'es');
$map[$m['file']]=$id; $created++;
}
echo "creados=$created skip=$skip total=".count($map)."\n";
// repuntar 17990
$c=get_post(17990)->post_content; $n=0;
foreach($map as $file=>$id){
$url=get_permalink($id);
$c2=preg_replace('#href="anterior/'.preg_quote($file,'#').'\.htm"#i','href="'.$url.'"',$c,1,$cnt);
if($cnt>0){ $c=$c2; $n++; }
}
wp_update_post(["ID"=>17990,"post_content"=>$c]);
$rest=preg_match_all('#anterior/[\w-]+\.htm#i',get_post(17990)->post_content,$mm);
echo "17990 repuntados=$n/23 | anterior/*.htm restantes=$rest\n";