Skip to content

Instantly share code, notes, and snippets.

@izzygld
Created January 12, 2021 13:31
Show Gist options
  • Save izzygld/66262e2899952d72cc36d72d3fceab98 to your computer and use it in GitHub Desktop.
Save izzygld/66262e2899952d72cc36d72d3fceab98 to your computer and use it in GitHub Desktop.
<?php
add_filter( "gform_confirmation_anchor",function() {} );
//For backwards compatibility, load wordpress if it hasn't been loaded yet
//Will be used if this file is being called directly
if(!class_exists("RGForms")){
for ( $i = 0; $i < $depth = 10; $i++ ) {
$wp_root_path = str_repeat( '../', $i );
if ( file_exists("{$wp_root_path}wp-load.php" ) ) {
require_once("{$wp_root_path}wp-load.php");
require_once("{$wp_root_path}wp-admin/includes/admin.php");
break;
}
}
}
?>
<?php
$id = $_GET['id'];
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri();?>/assets/gf/formreset.min.css">
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri();?>/assets/gf/formsmain.min.css">
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri();?>/assets/gf/forms.css">
<style>
body {
margin: 0;
font: 16px/1.5 proxima-nova,sans-serif;
color: #444955;
font-weight: 400;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
.gform_button {
display: inline-block;
color: #fff !important;
width: auto !important;
background-color: #214ba7;
}
.validation_error h4 {
margin-top: 0;
color: inherit;
}
.validation_error .alert-link {
font-weight: bold;
}
.validation_error>p,
.validation_error>ul {
margin-bottom: 0;
}
.validation_error>p+p {
margin-top: 5px;
}
.validation_error hr {
border-top-color: #e6c1c7;
}
.validation_error .alert-link {
color: #953b39;
}
#gforms_confirmation_message {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}
#gforms_confirmation_message h4 {
margin-top: 0;
color: inherit;
}
#gforms_confirmation_message .alert-link {
font-weight: bold;
}
#gforms_confirmation_message>p,
#gforms_confirmation_message>ul {
margin-bottom: 0;
}
#gforms_confirmation_message>p+p {
margin-top: 5px; }
.ginput_card_security_code {
display: inline-block !important;
}
.ginput_container_creditcard {
padding: 20px;
background: #efefef;
border-radius: 4px;
}
.name_prefix.name_prefix_select{
display: block !important;
}
.name_prefix.name_prefix_select select {
display: block !important;
width: 50% !important;
}
.gform_wrapper .donate-gf-styles ul.gfield_radio li {
padding: 10px 10px !important;
background: #efefef;
border-radius: 4px;
font-size: 18px;
}
#ui-datepicker-div {
background: white;
padding: 10px;
}
a.ui-datepicker-next.ui-corner-all {
float: right;
}
@media (min-width: 720px) {
.gform_wrapper .gf__ul-col--2 ul{
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
.gform_wrapper .gf__ul-col--2 ul li {
display: inline-block;
width: 100%;
}
.gform_wrapper .gf__ul-col--3 ul{
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
.gform_wrapper .gf__ul-col--3 ul li {
display: inline-block;
width: 100%;
}
}
.gform_wrapper li.gfield ul.gfield_radio li input[type=radio]+input[type=text] {
margin-left: 25px;
}
.ginput_complex.ginput_container label {
text-transform: none;
color: #666;
font-weight: 600 !important;
font-size: 10px !important;
}
</style>
<?php
require_once(GFCommon::get_base_path() . "/form_display.php");
$form = RGFormsModel::get_form_meta($id);
GFFormDisplay::enqueue_form_scripts($form, true);
//OUGFCheckout::load_javascript();
wp_print_scripts();
$styles = apply_filters("gform_preview_styles", array(), $form);
if(!empty($styles)){
wp_print_styles($styles);
}
?>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-resize/1.1/jquery.ba-resize.js"></script>
<script>
if(!window.addEventListener) {
window.addEventListener = function(event,fn) {
window.attachEvent('on'+event,fn);
};
}
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
resize = function() {
parent.postMessage(JSON.stringify({action:'resize',value:getDocHeight()+32}),'*');
}
jQuery(function($){
$(".gform_wrapper").on('resize',resize)
})
parent.postMessage(JSON.stringify({action:'ready'}),'*');
window.addEventListener("message", addCSS, false);
var ie8andless = !+"\v1";
// this is the callback handler to process the event
function addCSS(event)
{
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
if (ie8andless) {
hrefs = event.data.split("\n");
for(i = 0; i < hrefs.length; i++) {
var style = document.createElement('link');
style.type = 'text/css';
style.rel='stylesheet';
style.href=hrefs[i];
head.appendChild(style);
}
return;
}
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = event.data;
} else {
style.appendChild(document.createTextNode(event.data));
}
head.appendChild(style);
resize();
}
</script>
</head>
<body>
<?php
$title = json_decode($_GET['title']);
$description = json_decode($_GET['description']);
?>
<?php
$form = preg_replace("/document.location.href='(.*?)'/",'parent.postMessage(JSON.stringify({action:"redirect",value:"${1}"}),"*")',RGForms::get_form($id, $title, $description, true,true,true));
$form = str_replace("<div id='gforms_confirmation_message'", "<script>setTimeout(function() {parent.parent.postMessage(JSON.stringify({action:'showForm'}),'*')})</script><div id='gforms_confirmation_message'",$form);
$form = str_replace("jQuery('#gform_ajax_frame_3').load( function(){", "jQuery('#gform_ajax_frame_3').load( function(){debugger;", $form);
echo $form;
?>
<?php
do_action("gform_preview_footer");
?>
<script>
jQuery(document).on('gform_page_loaded',function() {
parent.postMessage(JSON.stringify({action:'showForm'}),'*');
});
jQuery(document).on('gform_confirmation_loaded',function() {
parent.postMessage(JSON.stringify({action:'showForm'}),'*');
});
jQuery('a').click(function (e) {
parent.postMessage(JSON.stringify({action:'redirect', value: this.href}),'*')
e.preventDefault()
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment