Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | public static function setSrcDataAttribute($nodeHtml, $elementTagName, $attributeName, $toAddGetParams) |
||
10 | { |
||
11 | $output = ''; |
||
12 | $DOM = new DOMDocument(); |
||
13 | $DOM->loadHTML($nodeHtml); |
||
14 | $domNodes = $DOM->getElementsByTagName($elementTagName); |
||
15 | |||
16 | foreach ($domNodes as $node) { |
||
17 | $attribute = $node->getAttribute($attributeName); |
||
18 | $attribute = add_query_arg($toAddGetParams, $attribute); |
||
19 | $node->removeAttribute($attributeName); |
||
20 | $node->setAttribute("data-{$attributeName}", $attribute); |
||
21 | $output .= $DOM->saveHTML($node); |
||
22 | } |
||
23 | return $output; |
||
24 | } |
||
25 | } |
||
26 |