Cómo evitar que el editor visual arruine mi iframe
18 sept 2018, 16:12:05
Vistas: 303
Votos: 2
Tengo este iframe
y JavaScript incrustado en una publicación:
<iframe onload="fa_iframeresize.do(this);" src="https://example.com/calc.php?tp=dif&cl=beleggen&h=1&wf=19370&country=NL" scrolling="no" width="100%" style="padding:0px;margin:0px;border-width:0px;" frameborder="0">
</iframe>
<script type="text/javascript" src="//example.com/iframeResizeMe.min.js.gz"></script>
Pero cada vez que voy al editor visual, el HTML se modifica ligeramente de manera que el código de example.com no puede manejarlo:
<iframe style="padding: 0px; margin: 0px; border-width: 0px;" src="https://example.com/calc.php?tp=dif&cl=beleggen&h=1&wf=19370&country=NL" width="100%" frameborder="0" scrolling="no">
</iframe>
<script type="text/javascript" src="//example.com/iframeResizeMe.min.js.gz"></script>
¿Existe alguna manera de evitar que el editor visual cambie un bloque de HTML?
Probé la extensión de iframe pero no lo manejó correctamente. También me gustaría evitar crear mi propio plugin para esto.
Idealmente me gustaría algo como <!-- NOREFORMAT --><iframe></iframe><script></script><!-- /NOREFORMAT -->
.

the
1.54K
Comentarios
Todas las respuestas a la pregunta
1
0
add_shortcode('custom_iframe_shortcode', 'build_iframe');
function build_iframe($atts) {
$defaults = array(
'source' => 'https://example.com/calc.php?tp=dif&cl=beleggen&h=1&wf=19370&country=NL',
'script_source' => '//example.com/iframeResizeMe.min.js.gz'
);
$args = shortcode_atts($defaults, $atts);
ob_start(); ?>
<iframe onload="fa_iframeresize.do(this);" src="<?php echo $args['source']; ?>" scrolling="no" width="100%" style="padding:0px;margin:0px;border-width:0px;" frameborder="0">
</iframe>
<script type="text/javascript" src="<?php echo $args['script_source']; ?>"></script>
<?php return ob_get_clean();
}
luego llámalo así [build_iframe]
o [build_iframe source="https://ejemplo" script_source="https://ejemplo/script.js"]

mrben522
1.68K
17 dic 2018 18:58:15
Preguntas relacionadas
2
respuestas
1
respuestas
1
respuestas