Skip to content

Instantly share code, notes, and snippets.

@hostedpixel
Created November 22, 2017 17:05
Show Gist options
  • Save hostedpixel/1a9e5b82a80618c616c7cabff3e8c808 to your computer and use it in GitHub Desktop.
Save hostedpixel/1a9e5b82a80618c616c7cabff3e8c808 to your computer and use it in GitHub Desktop.

Revisions

  1. hostedpixel created this gist Nov 22, 2017.
    28 changes: 28 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@

    // Pardot form

    function pardot_form( $atts ) {
    $a = shortcode_atts( array(
    'mobile-height' => '900',
    'height' => '500',
    'class' => '',
    'form' => ''
    ), $atts );

    return '<script type="text/javascript">
    pardot_mobile_height = ' . $a['mobile-height'] . ';
    pardot_desktop_height = ' . $a['height'] . ';
    onResize = function() {
    if (window.innerWidth < 1181) {
    console.log("smaller");
    jQuery("iframe").attr("height", pardot_mobile_height);
    } else {
    console.log("taller");
    jQuery("iframe").attr("height", pardot_desktop_height);
    }
    }
    jQuery(window).resize(onResize);
    jQuery(document).ready(onResize);
    </script><iframe src="' . $a['form'] . '" width="100%" height="' . $a['height'] . '" class="' . $a['class'] . '" type="text/html" frameborder="0" allowTransparency="true" style="border: 0"></iframe>';
    }
    add_shortcode( 'pardot', 'pardot_form' );