Come evitare che l'editor visivo modifichi il mio iframe?
18 set 2018, 16:12:05
Visualizzazioni: 303
Voti: 2
Ho inserito questo iframe
e JavaScript in un articolo:
<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>
Ma ogni volta che accedo all'editor visivo, l'HTML viene modificato leggermente in un modo che il codice di example.com non riesce più a gestire:
<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>
Esiste un modo per impedire all'editor visivo di modificare un blocco di HTML?
Ho provato l'estensione per iframe ma non ha funzionato correttamente. Vorrei anche evitare di creare un plugin personalizzato per questo.
Idealmente mi piacerebbe qualcosa come <!-- NOREFORMAT --><iframe></iframe><script></script><!-- /NOREFORMAT -->
.

the
1.54K
Commenti
Tutte le risposte alla domanda
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();
}
puoi chiamarlo così [build_iframe]
oppure [build_iframe source="https://blah" script_source="https://blah/blah.js']

mrben522
1.68K
17 dic 2018 18:58:15
Domande correlate