PluginProbe
WindPress – Tailwind CSS integration for WordPress / 3.2.91
WindPress – Tailwind CSS integration for WordPress v3.2.91
3.2.91 3.2.92 3.2.90 3.2.89 3.2.88 3.2.87 3.2.86 3.2.85 3.2.84 3.2.83 3.2.82 3.2.81 trunk 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.2 3.0.3 All 146 releases
windpress / vendor / enshrined / svg-sanitize / src / Helper.php

Helper.php in WindPress – Tailwind CSS integration for WordPress 3.2.91, at vendor/enshrined/svg-sanitize/src/Helper.php

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WindPressDeps\enshrined\svgSanitize;
4
5 class Helper
6 {
7 /**
8 * @param \DOMElement $element
9 * @return string|null
10 */
11 public static function getElementHref(\DOMElement $element)
12 {
13 if ($element->hasAttribute('href')) {
14 return $element->getAttribute('href');
15 }
16 if ($element->hasAttributeNS('http://www.w3.org/1999/xlink', 'href')) {
17 return $element->getAttributeNS('http://www.w3.org/1999/xlink', 'href');
18 }
19 return null;
20 }
21 /**
22 * @param string $href
23 * @return string|null
24 */
25 public static function extractIdReferenceFromHref($href)
26 {
27 if (!is_string($href) || strpos($href, '#') !== 0) {
28 return null;
29 }
30 return substr($href, 1);
31 }
32 /**
33 * @param \DOMElement $needle
34 * @param \DOMElement $haystack
35 * @return bool
36 */
37 public static function isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
38 {
39 if ($needle === $haystack) {
40 return \true;
41 }
42 foreach ($haystack->childNodes as $childNode) {
43 if (!$childNode instanceof \DOMElement) {
44 continue;
45 }
46 if (self::isElementContainedIn($needle, $childNode)) {
47 return \true;
48 }
49 }
50 return \false;
51 }
52 }
53