-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
46 lines (39 loc) · 851 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
Kirby::plugin('moritzebeling/kirbytext-external-links', [
'tags' => [
'link' => [
'attr' => [
'class',
'lang',
'rel',
'role',
'target',
'title',
'text',
],
'html' => function ($tag) {
if (empty( $tag->lang ) === false) {
$tag->value = Url::to($tag->value, $tag->lang);
}
if (empty( $tag->target )) {
if ($domain = parse_url( $tag->value )) {
if (isset( $domain['host'] )) {
$tag->target = '_blank';
$tag->rel = 'noopener noreferrer';
if (empty( $tag->text )) {
$tag->text = $domain['host'];
}
}
}
}
return Html::a($tag->value, $tag->text, [
'rel' => $tag->rel,
'class' => $tag->class,
'role' => $tag->role,
'title' => $tag->title,
'target' => $tag->target,
]);
}
],
]
]);