PluginProbe
Gutenberg / 23.5.2
Gutenberg v23.5.2
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / compat / wordpress-7.1 / kses.php

kses.php in Gutenberg 23.5.2, at lib/compat/wordpress-7.1/kses.php

100 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Compatibility shims for KSES (content filtering) for WordPress 7.1.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Adds SVG presentation attributes to the list of safe CSS properties.
10 *
11 * The {@see safecss_filter_attr()} function only keeps allowlisted CSS properties, so SVG
12 * presentation attributes such as `fill` are stripped by default. This allows
13 * the SVG-specific ones.
14 *
15 * @param string[] $attr Array of allowed CSS attributes.
16 * @return string[] Modified array of allowed CSS attributes.
17 */
18 function gutenberg_add_svg_to_safe_style_css( array $attr ): array {
19 $svg_properties = array(
20 // Fill.
21 'fill',
22 'fill-opacity',
23 'fill-rule',
24
25 // Stroke.
26 'stroke',
27 'stroke-dasharray',
28 'stroke-dashoffset',
29 'stroke-linecap',
30 'stroke-linejoin',
31 'stroke-miterlimit',
32 'stroke-opacity',
33 'stroke-width',
34
35 // Paint.
36 'color-interpolation',
37 'color-interpolation-filters',
38 'paint-order',
39 'stop-color',
40 'stop-opacity',
41 'flood-color',
42 'flood-opacity',
43 'lighting-color',
44
45 // Markers.
46 'marker',
47 'marker-end',
48 'marker-mid',
49 'marker-start',
50
51 // Clipping and masking.
52 'clip-path',
53 'clip-rule',
54 'mask',
55 'mask-type',
56
57 // Geometry.
58 'cx',
59 'cy',
60 'r',
61 'rx',
62 'ry',
63 'x',
64 'y',
65 'd',
66
67 // Text.
68 'alignment-baseline',
69 'baseline-shift',
70 'dominant-baseline',
71 'glyph-orientation-horizontal',
72 'glyph-orientation-vertical',
73 'text-anchor',
74 'unicode-bidi',
75 'word-spacing',
76
77 // Font.
78 'font-size-adjust',
79 'font-stretch',
80
81 // Rendering.
82 'color-rendering',
83 'image-rendering',
84 'shape-rendering',
85 'text-rendering',
86 'vector-effect',
87
88 // Transforms.
89 'transform',
90 'transform-origin',
91
92 // Interactivity and visibility.
93 'pointer-events',
94 'visibility',
95 );
96
97 return array_unique( array_merge( $attr, $svg_properties ) );
98 }
99 add_filter( 'safe_style_css', 'gutenberg_add_svg_to_safe_style_css' );
100