scripts(homenajes): migración Mardones/Galarreta + sync prod #130/#131/#133/#137/#138
Pipeline de los 23 posts de Mardones (anterior/*.htm → posts), repunte de presentaciones de Galarreta, y scripts de sync a prod de las 5 issues del día. Incluye retoques de fecha (2012-10-10) y eliminación de target=_blank en el homenaje 17990. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?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";
|
||||
Reference in New Issue
Block a user