| @@ -1,4 +1,48 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +// This file is included via Render::view() using extract(); all variables below are in the calling method's local scope, not global namespace. | |
| 4 | + | |
| 5 | +use BitCode\BitForm\Core\Util\EscapingHelper; | |
| 6 | +use BitCode\BitForm\Core\Util\FrontendHelpers; | |
| 7 | + | |
| 8 | +if (!defined('ABSPATH')) { | |
| 9 | + exit; | |
| 10 | +} | |
| 11 | +if (!defined('BITFORMS_ASSET_URI')) { | |
| 12 | + exit; | |
| 13 | +} | |
| 14 | + | |
| 15 | +$formUpdateVersion = get_option('bitform_form_update_version'); | |
| 16 | +$formIdSafe = sanitize_key((string) $formID); | |
| 17 | + | |
| 18 | +$bitformCssUrl = FrontendHelpers::styleSrc('form-styles/bitform-' . $formID . '.css'); | |
| 19 | +$bitformFormIdCssUrl = FrontendHelpers::styleSrc('form-styles/bitform-' . $formID . '-formid.css'); | |
| 20 | +$customCssSubPath = "/form-styles/bitform-custom-{$formID}.css"; | |
| 21 | + | |
| 22 | +wp_register_style('bitform-entry-edit-base-' . $formIdSafe, $bitformCssUrl, [], $formUpdateVersion); | |
| 23 | +wp_register_style('bitform-entry-edit-formid-' . $formIdSafe, $bitformFormIdCssUrl, [], $formUpdateVersion); | |
| 24 | +wp_enqueue_style('bitform-entry-edit-base-' . $formIdSafe); | |
| 25 | +wp_enqueue_style('bitform-entry-edit-formid-' . $formIdSafe); | |
| 26 | + | |
| 27 | +if (file_exists(BITFORMS_CONTENT_DIR . $customCssSubPath)) { | |
| 28 | + wp_register_style('bitform-entry-edit-custom-' . $formIdSafe, FrontendHelpers::styleSrc($customCssSubPath), [], $formUpdateVersion); | |
| 29 | + wp_enqueue_style('bitform-entry-edit-custom-' . $formIdSafe); | |
| 30 | +} | |
| 31 | + | |
| 32 | +if (isset($font) && '' !== $font) { | |
| 33 | + wp_register_style('bitform-entry-edit-font-' . $formIdSafe, $font, [], $formUpdateVersion); | |
| 34 | + wp_enqueue_style('bitform-entry-edit-font-' . $formIdSafe); | |
| 35 | +} | |
| 36 | + | |
| 37 | +$previewJsPath = BITFORMS_UPLOAD_BASE_URL . '/form-scripts/preview-' . $formID . '.js'; | |
| 38 | +wp_register_script('bitform-entry-edit-' . $formIdSafe, $previewJsPath, [], $formUpdateVersion, true); | |
| 39 | +wp_enqueue_script('bitform-entry-edit-' . $formIdSafe); | |
| 40 | +if (isset($bfGlobals) && '' !== $bfGlobals) { | |
| 41 | + wp_add_inline_script('bitform-entry-edit-' . $formIdSafe, (string) $bfGlobals, 'before'); | |
| 42 | +} | |
| 43 | +?> | |
| 44 | + | |
| 1 | 45 | <!DOCTYPE html> |
| 2 | 46 | <html lang="en"> |
| 3 | 47 | |
| 4 | 48 | <head> |
| @@ -4,9 +48,9 @@ | ||
| 4 | 48 | <head> |
| 5 | 49 | <meta charset="UTF-8"> |
| 6 | 50 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 7 | 51 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 8 | - <title><?php echo isset($title) ? $title : ''; ?></title> | |
| 52 | + <title><?php echo isset($title) ? esc_html($title) : ''; ?></title> | |
| 9 | 53 | <style> |
| 10 | 54 | html, |
| 11 | 55 | body { |
| 12 | 56 | min-height: 100%; |
| @@ -19,43 +63,31 @@ | ||
| 19 | 63 | flex-direction: column; |
| 20 | 64 | /* background-color: #f1f1f1; */ |
| 21 | 65 | } |
| 22 | 66 | |
| 23 | - ._frm-bg-b<?php echo $formID; | |
| 24 | - | |
| 25 | - ?> { | |
| 67 | + ._frm-bg-b<?php echo esc_html($formID); ?> { | |
| 26 | 68 | width: 600px; |
| 27 | 69 | margin-block: 100px; |
| 28 | 70 | } |
| 29 | 71 | </style> |
| 30 | - <?php | |
| 31 | - $formUpdateVersion = get_option('bit-form_form_update_version'); | |
| 32 | - ?> | |
| 33 | - <link rel="stylesheet" | |
| 34 | - href="<?php echo BITFORMS_UPLOAD_BASE_URL?>/form-styles/bitform-<?php echo $formID?>.css?ver=<?php echo $formUpdateVersion?>" /> | |
| 35 | - <?php | |
| 36 | - $customCssSubPath = "/form-styles/bitform-custom-{$formID}.css"; | |
| 37 | - ?> | |
| 38 | - <?php if(file_exists(BITFORMS_CONTENT_DIR . $customCssSubPath)) : ?> | |
| 39 | - <link rel="stylesheet" | |
| 40 | - href="<?php echo BITFORMS_UPLOAD_BASE_URL . $customCssSubPath ?>?ver=<?php echo $formUpdateVersion?>" /> | |
| 41 | - <?php endif; ?> | |
| 42 | - | |
| 43 | - <?php if (isset($font) && '' !== $font): ?> | |
| 72 | + <?php if (isset($font) && '' !== $font) : ?> | |
| 44 | 73 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
| 45 | 74 | <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 46 | - <link rel="stylesheet" href="<?php echo $font?>" /> | |
| 47 | 75 | <?php endif; ?> |
| 48 | - | |
| 76 | + <?php | |
| 77 | + wp_enqueue_emoji_styles(); | |
| 78 | + wp_print_styles(); | |
| 79 | + ?> | |
| 49 | 80 | </head> |
| 50 | 81 | |
| 51 | 82 | <body> |
| 52 | - <?php echo $formHTML?> | |
| 83 | + <?php | |
| 84 | + // Fallback config for when an optimizer defers or drops the inline script. | |
| 85 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built by buildFormConfigTag(), JSON_HEX_* escaped. | |
| 86 | + echo isset($configTag) ? $configTag : ''; | |
| 87 | + ?> | |
| 88 | + <?php echo wp_kses($formHTML, EscapingHelper::getFormAllowedHtml(isset($formContent) ? $formContent : null)); ?> | |
| 53 | 89 | |
| 54 | - <script> | |
| 55 | - <?php echo $bfGlobals?>; | |
| 56 | - </script> | |
| 57 | - <script src="<?php echo BITFORMS_UPLOAD_BASE_URL?>/form-scripts/preview-<?php echo $formID?>.js"></script> | |
| 58 | - | |
| 90 | + <?php wp_print_scripts(); ?> | |
| 59 | 91 | </body> |
| 60 | 92 | |
| 61 | -</html> | |
| 93 | +</html> | |