<?php
// 1) presentaciones-gala 19107: repuntar 10
$map=[
 "sugerencias-para-las-bodas"=>19105,"el-eterno-problema-del-mundo-y-los-hijos"=>19104,
 "necesitamos-un-pepe"=>19102,"lucas-18-1-8"=>19106,"el-perdon-primero"=>19101,
 "alabar-a-dios-y-darle-gracias"=>19119,"2-reyes-5-14-17-2-timoteo-2-8-13"=>19123,
 "creer-en-dios-es-apostar-por-la-vida"=>19132,"lucas-17-5-10"=>19131,"la-gran-evasion"=>19143,
];
$c=get_post(19107)->post_content; $n=0;
foreach($map as $bad=>$dst){
  if(!get_post($dst)){ echo "  dst $dst NO EXISTE\n"; continue; }
  $url=get_permalink($dst);
  $c2=preg_replace('#https?://[^"]*?/'.preg_quote($bad,'#').'/#',$url,$c,1,$cnt);
  if($cnt>0){ $c=$c2; $n++; }
}
wp_update_post(["ID"=>19107,"post_content"=>$c]);
echo "presentaciones repuntadas: $n/10\n";
// 2) libros + youtube en 17918
$c=get_post(17918)->post_content;
$ext="https://edicionesfeadulta.com/?filters=autor[galarreta]";
$c=preg_replace('#https?://[^"]*?/libros-y-e-books/#',$ext,$c,-1,$cl);
$c=preg_replace('#(<a [^>]*href=")'.preg_quote($ext,'#').'("(?![^>]*target))#','$1'.$ext.'$2 target="_blank" rel="noopener"',$c);
$c=str_replace('src="//www.youtube.com/embed/','src="https://www.youtube.com/embed/',$c);
wp_update_post(["ID"=>17918,"post_content"=>$c]);
echo "libros->externo: $cl | youtube https aplicado | foto JE: ".(strpos($c,'edicionesfeadulta.com')!==false?'ok':'?')."\n";
