window.addEventListener('message',function(e){ if(e.data&&e.data.mf_nav)window.location.href=e.data.mf_nav; });
// Verificar sesión WP desde la página padre (tiene cookies completas) y notificar al iframe (async function(){ try{ var r=await fetch('/wp-json/wp/v2/users/me?context=view',{credentials:'include',cache:'no-store'}); if(!r.ok)return; var u=await r.json(); if(!u||!u.id)return; // Usuario logueado en WP = Gold automático var msg={mf_plan:'g',mf_user:{id:u.id,name:u.name||''}}; var fr=document.getElementById('myfeditor'); function send(){try{fr.contentWindow.postMessage(msg,'*');}catch(e){}} // Enviar inmediatamente y también al cargar el iframe send(); fr.addEventListener('load',function(){send();setTimeout(send,300);setTimeout(send,800);}); }catch(e){} })();