@times-design-system/components-wordpress 1.8.0 → 1.8.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/blocks/ad-container/block.json +3 -1
- package/dist/blocks/button/block.json +5 -6
- package/dist/blocks/button/edit.js +15 -21
- package/dist/blocks/button/render.php +43 -46
- package/dist/blocks/button/save.js +13 -19
- package/dist/blocks/button/style.css +8 -25
- package/dist/blocks/chip/block.json +7 -3
- package/dist/blocks/chip/render.php +1 -1
- package/dist/blocks/chip/style.css +3 -3
- package/dist/blocks/dialog-box/block.json +2 -1
- package/dist/blocks/divider/block.json +3 -1
- package/dist/blocks/flag/block.json +7 -3
- package/dist/blocks/flag/style.css +19 -22
- package/dist/blocks/icon/block.json +3 -2
- package/dist/blocks/icon/render.php +1 -1
- package/dist/blocks/icon-button/block.json +5 -2
- package/dist/blocks/icon-button/render.php +3 -2
- package/dist/blocks/icon-button/style.css +9 -8
- package/dist/blocks/input/block.json +3 -1
- package/dist/blocks/input/style.css +31 -17
- package/dist/blocks/input-helper-message/block.json +2 -1
- package/dist/blocks/link/block.json +7 -3
- package/dist/blocks/link/style.css +123 -21
- package/dist/blocks/tab/block.json +2 -1
- package/dist/blocks/tab/style.css +146 -17
- package/dist/blocks/tab-group/block.json +2 -1
- package/dist/blocks/text/block.json +3 -1
- package/dist/blocks/toast/block.json +3 -1
- package/dist/blocks/toast/style.css +32 -31
- package/dist/blocks/utils/render-icon.php +39 -0
- package/dist/blocks/utils/sanitize-data-attributes.php +37 -0
- package/dist/icon-data.json +3895 -1952
- package/dist/index.cjs +997 -278
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +998 -279
- package/dist/index.js.map +1 -1
- package/dist/plugin.php +162 -12
- package/dist/utils/render-icon.php +32 -6
- package/package.json +9 -6
- package/plugin.php +162 -12
- package/dist/blocks/button/style-editor.css +0 -15
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Data Attributes Sanitization Utility
|
|
4
|
+
*
|
|
5
|
+
* Sanitizes and prepares data-* attributes for blocks.
|
|
6
|
+
*
|
|
7
|
+
* @package TimesDesignSystem\ComponentsWordPress
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
if (!function_exists('tds_sanitize_data_attributes')) {
|
|
11
|
+
/**
|
|
12
|
+
* Sanitize data-* attributes for a block
|
|
13
|
+
*
|
|
14
|
+
* @param array $attributes Data attributes to sanitize
|
|
15
|
+
* @param string $block_name Name of the block
|
|
16
|
+
* @param array $full_attributes Full block attributes array
|
|
17
|
+
* @return array Sanitized data attributes
|
|
18
|
+
*/
|
|
19
|
+
function tds_sanitize_data_attributes($attributes = [], $block_name = '', $full_attributes = []) {
|
|
20
|
+
if (!is_array($attributes)) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$sanitized = [];
|
|
25
|
+
foreach ($attributes as $key => $value) {
|
|
26
|
+
// Sanitize the key and value
|
|
27
|
+
$safe_key = 'data-' . sanitize_html_class($key);
|
|
28
|
+
$safe_value = sanitize_text_field($value);
|
|
29
|
+
|
|
30
|
+
if ($safe_key && $safe_value) {
|
|
31
|
+
$sanitized[$safe_key] = $safe_value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return $sanitized;
|
|
36
|
+
}
|
|
37
|
+
}
|