PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.13
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.13
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Util / EscapingHelper.php

EscapingHelper.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.21.13, at includes/Core/Util/EscapingHelper.php

40 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Util;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 /**
10 * Helper for escaping output with configurable allowed HTML tags.
11 */
12 final class EscapingHelper
13 {
14 /**
15 * Returns the default allowed HTML tags for form/shortcode output.
16 * Filterable via 'bitforms_allowed_html_tags'.
17 *
18 * @return array<string, array<string, bool>> wp_kses-compatible allowed tags and attributes
19 */
20 public static function getAllowedHtmlTags()
21 {
22 $default = wp_kses_allowed_html('post');
23 $default['script'] = array_fill_keys(['type', 'src', 'id', 'async', 'defer'], true);
24 $default['style'] = array_fill_keys(['type', 'id'], true);
25 $allowed = apply_filters('bitforms_allowed_html_tags', $default);
26 return is_array($allowed) ? $allowed : $default;
27 }
28
29 /**
30 * Sanitizes HTML for form/shortcode output using the filterable allowed tags list.
31 *
32 * @param string $html Raw HTML to sanitize
33 * @return string Sanitized HTML
34 */
35 public static function ksesFormOutput($html)
36 {
37 return wp_kses($html, self::getAllowedHtmlTags());
38 }
39 }
40