form-preview.php
92 lines
| 1 | <?php |
| 2 | |
| 3 | // same as default WP from wp-admin/admin-header.php. |
| 4 | $wp_version_class = 'branch-' . str_replace(['.', ','], '-', floatval(get_bloginfo('version'))); |
| 5 | |
| 6 | set_current_screen(); |
| 7 | ?> |
| 8 | |
| 9 | <!DOCTYPE html> |
| 10 | <html <?php |
| 11 | language_attributes(); ?>> |
| 12 | <head> |
| 13 | <meta name="viewport" content="width=device-width" /> |
| 14 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 15 | <title><?php |
| 16 | esc_html_e('GiveWP › Onboarding Wizard', 'give'); ?></title> |
| 17 | <?php |
| 18 | wp_print_styles(['give-styles']); ?> |
| 19 | |
| 20 | <style> |
| 21 | body { |
| 22 | margin: 0; |
| 23 | padding: 0; |
| 24 | } |
| 25 | |
| 26 | .iframe-loader { |
| 27 | min-height: 776px !important; |
| 28 | } |
| 29 | </style> |
| 30 | </head> |
| 31 | <body class="<?php |
| 32 | echo esc_attr($wp_version_class); ?>"> |
| 33 | <?php |
| 34 | echo give_form_shortcode( |
| 35 | [ |
| 36 | 'id' => $this->get_preview_form_id(), |
| 37 | ] |
| 38 | ); |
| 39 | ?> |
| 40 | <?php |
| 41 | wp_print_scripts(['give']); ?> |
| 42 | <script> |
| 43 | (function checkForBodySizeChange() { |
| 44 | var last_body_size = { |
| 45 | width: document.body.clientWidth, |
| 46 | height: document.body.clientHeight, |
| 47 | }; |
| 48 | |
| 49 | function checkBodySizeChange() { |
| 50 | var width_changed = last_body_size.width !== document.body.clientWidth, |
| 51 | height_changed = last_body_size.height !== document.body.clientHeight; |
| 52 | |
| 53 | |
| 54 | if (width_changed || height_changed) { |
| 55 | handleBodySizeChange(document.body.clientWidth, document.body.clientHeight); |
| 56 | last_body_size = { |
| 57 | width: document.body.clientWidth, |
| 58 | height: document.body.clientHeight, |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | window.requestAnimationFrame(checkBodySizeChange); |
| 63 | } |
| 64 | |
| 65 | function handleBodySizeChange(width, height) { |
| 66 | window.parent.postMessage({ |
| 67 | action: 'resize', |
| 68 | payload: { |
| 69 | height, |
| 70 | width, |
| 71 | }, |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | window.requestAnimationFrame(checkBodySizeChange); |
| 76 | })(); |
| 77 | </script> |
| 78 | <script> |
| 79 | (function listenForFormLoaded() { |
| 80 | function handleFormLoaded(width, height) { |
| 81 | window.parent.postMessage({ |
| 82 | action: 'loaded', |
| 83 | payload: {}, |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | document.querySelector('iframe').addEventListener('load', handleFormLoaded); |
| 88 | })(); |
| 89 | </script> |
| 90 | </body> |
| 91 | </html> |
| 92 |