File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -49,11 +49,22 @@ public function get_svg($id, $opts=[]) {
49
49
}
50
50
51
51
52
+ // $opts[aria-*]
53
+ // strlen('aria-') = 5
54
+ $ aria_opts = array_filter ($ opts , function ($ item , $ key ){
55
+ if (substr ($ key , 0 , 5 ) == 'aria- ' ) return $ item ;
56
+ }, ARRAY_FILTER_USE_BOTH );
57
+
52
58
53
59
54
60
foreach ($ doc ->getElementsByTagName ('svg ' ) as $ item ) {
55
61
if ($ classes != '' ) $ item ->setAttribute ('class ' , $ classes );
56
62
if ($ opts ['role ' ]) $ item ->setAttribute ('role ' , $ opts ['role ' ]);
63
+
64
+
65
+ foreach ($ aria_opts as $ key => $ val ) {
66
+ $ item ->setAttribute ($ key , $ val );
67
+ }
57
68
58
69
59
70
if ($ opts ['title ' ]) {
@@ -69,11 +80,13 @@ public function get_svg($id, $opts=[]) {
69
80
$ item ->setAttribute ('aria-labelledby ' , $ title_id );
70
81
}
71
82
72
- } else {
83
+ } elseif ( isset ( $ aria_opts [ ' aria-hidden ' ])) {
73
84
$ item ->setAttribute ('aria-hidden ' , 'true ' );
74
85
}
75
86
}
76
87
88
+
89
+
77
90
foreach ($ doc ->getElementsByTagName ('path ' ) as $ item ) {
78
91
$ item ->setAttribute ('fill ' , $ opts ['fill ' ]);
79
92
}
You can’t perform that action at this time.
0 commit comments