Example #1
0
            $figure->append('<figcaption>' . html($caption) . '</figcaption>');
        }
        return $figure;
    } else {
        $class = trim($tag->attr('class') . ' ' . $tag->attr('imgclass'));
        return $_link($_image($class));
    }
});
// link tag
kirbytext::$tags['link'] = array('attr' => array('text', 'class', 'title', 'rel', 'target', 'popup'), 'html' => function ($tag) {
    $link = url($tag->attr('link'));
    $text = $tag->attr('text');
    if (empty($text)) {
        $text = escape::attr($link);
    } else {
        if (str::isURL($text)) {
            $text = escape::attr($text);
        }
    }
    return html::a($link, $text, array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => $tag->attr('title'), 'target' => $tag->target()));
});
// tel tag
kirbytext::$tags['tel'] = array('attr' => array('text', 'class', 'title'), 'html' => function ($tag) {
    $text = $tag->attr('text');
    $tel = str_replace(array('/', ' ', '-'), '', $tag->attr('tel'));
    if (empty($text)) {
        $text = $tag->attr('tel');
    }
    return html::a('tel:' . $tel, html($text), array('rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => html($tag->attr('title'))));
});
// twitter tag
Example #2
0
<?php

// override to target="_blank" if external link
kirbytext::$tags['link'] = ['attr' => array('text', 'class', 'title', 'rel', 'lang', 'target', 'popup'), 'html' => function ($tag) {
    $link = url($tag->attr('link'), $tag->attr('lang'));
    $text = $tag->attr('text');
    if (empty($text)) {
        $text = $link;
    }
    if (str::isURL($text)) {
        $text = url::short($text);
    }
    return html::a($link, $text, ['rel' => $tag->attr('rel'), 'class' => $tag->attr('class'), 'title' => $tag->attr('title'), 'target' => str::isURL($tag->attr('link')) ? "_blank" : $tag->target()]);
}];