after-kubio-activation.php
4 months ago
allow-kubio-blog-override.php
2 years ago
cache-plugins.php
4 years ago
default-editor-overlay.php
1 year ago
dismissable-notice.php
1 month ago
gutenerg-plugin-check.php
1 year ago
image-size-auto-fix.php
1 year ago
kubio-fresh-site.php
2 years ago
post-insert.php
4 months ago
register-meta-fields.php
3 years ago
requirements-notices.php
1 year ago
site-urls.php
1 year ago
starter-sites-feature.php
1 year ago
svg-kses.php
1 year ago
wp-import.php
3 months ago
svg-kses.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | function kubio_get_svg_kses_allowed_elements( $allowed_html = array() ) { |
| 4 | |
| 5 | $svg_elements = array( |
| 6 | 'svg' => |
| 7 | array( |
| 8 | 'xmlns', |
| 9 | 'viewbox', |
| 10 | 'id', |
| 11 | 'data-name', |
| 12 | 'width', |
| 13 | 'height', |
| 14 | 'version', |
| 15 | 'xmlns:xlink', |
| 16 | 'x', |
| 17 | 'y', |
| 18 | 'enable-background', |
| 19 | 'xml:space', |
| 20 | ), |
| 21 | 'path' => |
| 22 | array( |
| 23 | 'd', |
| 24 | 'id', |
| 25 | 'class', |
| 26 | 'data-name', |
| 27 | ), |
| 28 | 'g' => |
| 29 | array( |
| 30 | 'id', |
| 31 | 'stroke', |
| 32 | 'stroke-width', |
| 33 | 'fill', |
| 34 | 'fill-rule', |
| 35 | 'transform', |
| 36 | ), |
| 37 | 'title' => |
| 38 | array(), |
| 39 | 'polygon' => |
| 40 | array( |
| 41 | 'id', |
| 42 | 'points', |
| 43 | ), |
| 44 | 'rect' => |
| 45 | array( |
| 46 | 'x', |
| 47 | 'y', |
| 48 | 'width', |
| 49 | 'height', |
| 50 | 'transform', |
| 51 | ), |
| 52 | 'circle' => |
| 53 | array( |
| 54 | 'cx', |
| 55 | 'cy', |
| 56 | 'r', |
| 57 | ), |
| 58 | 'ellipse' => |
| 59 | array( |
| 60 | 'cx', |
| 61 | 'cy', |
| 62 | 'rx', |
| 63 | 'ry', |
| 64 | ), |
| 65 | ); |
| 66 | |
| 67 | $shared_attrs = array( 'data-*', 'id', 'class' ); |
| 68 | |
| 69 | foreach ( $svg_elements as $element => $attrs ) { |
| 70 | if ( ! isset( $allowed_html[ $element ] ) ) { |
| 71 | $allowed_html[ $element ] = array(); |
| 72 | } |
| 73 | |
| 74 | $allowed_html[ $element ] = array_merge( $allowed_html[ $element ], array_fill_keys( array_merge( $attrs, $shared_attrs ), true ) ); |
| 75 | } |
| 76 | |
| 77 | return $allowed_html; |
| 78 | } |
| 79 | |
| 80 | add_filter( 'wp_kses_allowed_html', 'kubio_get_svg_kses_allowed_elements' ); |
| 81 |