wizard
1 year ago
class-addons-template-util.php
1 year ago
class-allowed-template-html-util.php
1 year ago
class-base-exception.php
1 year ago
class-cache-constants.php
1 year ago
class-cache-exception.php
1 year ago
class-key-exception.php
1 year ago
class-keytypes.php
1 year ago
class-option-exception.php
1 year ago
class-quiet-skin.php
1 year ago
class-request-exception.php
1 year ago
class-script-translations.php
1 year ago
class-settings-exception.php
1 year ago
class-theme-installer-exception.php
1 year ago
class-theme-installer.php
1 year ago
class-allowed-template-html-util.php
80 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SuperbAddons\Data\Utils; |
| 4 | |
| 5 | defined('ABSPATH') || exit(); |
| 6 | |
| 7 | class AllowedTemplateHTMLUtil |
| 8 | { |
| 9 | public static function enable_safe_styles() |
| 10 | { |
| 11 | add_filter("safe_style_css", array(__CLASS__, "_add_display_safe_style_css")); |
| 12 | } |
| 13 | |
| 14 | public static function disable_safe_styles() |
| 15 | { |
| 16 | remove_filter("safe_style_css", array(__CLASS__, "_add_display_safe_style_css")); |
| 17 | } |
| 18 | |
| 19 | public static function get_allowed_html() |
| 20 | { |
| 21 | // Get 'post' allowed html tags for wp_kses |
| 22 | $allowed_html = wp_kses_allowed_html('post'); |
| 23 | // Add additional required tags |
| 24 | $allowed_html['select'] = array( |
| 25 | 'class' => true, |
| 26 | 'id' => true, |
| 27 | 'name' => true, |
| 28 | 'disabled' => true, |
| 29 | 'required' => true, |
| 30 | 'multiple' => true, |
| 31 | ); |
| 32 | $allowed_html['option'] = array( |
| 33 | 'class' => true, |
| 34 | 'id' => true, |
| 35 | 'name' => true, |
| 36 | 'value' => true, |
| 37 | 'selected' => true, |
| 38 | 'disabled' => true, |
| 39 | ); |
| 40 | $allowed_html['input'] = array( |
| 41 | 'class' => true, |
| 42 | 'id' => true, |
| 43 | 'name' => true, |
| 44 | 'type' => true, |
| 45 | 'value' => true, |
| 46 | 'checked' => true, |
| 47 | 'disabled' => true, |
| 48 | 'readonly' => true, |
| 49 | 'required' => true, |
| 50 | 'placeholder' => true, |
| 51 | 'maxlength' => true, |
| 52 | 'data-action' => true, |
| 53 | ); |
| 54 | $allowed_html['svg'] = array( |
| 55 | 'class' => true, |
| 56 | 'id' => true, |
| 57 | 'xmlns' => true, |
| 58 | 'width' => true, |
| 59 | 'height' => true, |
| 60 | 'viewbox' => true, |
| 61 | 'fill' => true, |
| 62 | ); |
| 63 | $allowed_html['path'] = array( |
| 64 | 'd' => true, |
| 65 | 'fill' => true, |
| 66 | ); |
| 67 | |
| 68 | return $allowed_html; |
| 69 | } |
| 70 | |
| 71 | public static function _add_display_safe_style_css($styles) |
| 72 | { |
| 73 | if (!is_array($styles)) { |
| 74 | $styles = []; |
| 75 | } |
| 76 | $styles[] = 'display'; |
| 77 | return $styles; |
| 78 | } |
| 79 | } |
| 80 |