Ejemplo n.º 1
0
function output_preview()
{
    $content = ob_get_contents();
    ob_end_clean();
    ob_start();
    $content = preg_replace("/\\<a href=\"(.*?)\"[\\s]?\\>(.*?)\\<\\/a\\>/", function ($matches) {
        return replace_href($matches[2], $matches[1]);
    }, $content);
    echo $content;
    exit;
}
Ejemplo n.º 2
0
function get_teaser($string, $url = null, $char = null)
{
    $teaserType = config('teaser.type');
    $more = config('read.more');
    if (empty($more)) {
        $more = 'Read more';
    }
    if (empty($char)) {
        $char = config('teaser.char');
        if (empty($char)) {
            $char = 200;
        }
    }
    if ($teaserType === 'full') {
        $readMore = explode('<!--more-->', $string);
        if (isset($readMore['1'])) {
            $patterns = array('<a id="more"></a><br>', '<p><a id="more"></a><br></p>');
            $string = str_replace($patterns, '', $readMore['0']);
            $string = replace_href($string, 'a', 'footnote-ref', $url);
            return $string . '<p class="jump-link"><a class="read-more btn btn-cta-secondary" href="' . $url . '#more">' . $more . '</a></p>';
        } else {
            return $string;
        }
    } elseif (strlen(strip_tags($string)) < $char) {
        $string = preg_replace('/\\s\\s+/', ' ', strip_tags($string));
        $string = ltrim(rtrim($string));
        return $string;
    } else {
        $string = preg_replace('/\\s\\s+/', ' ', strip_tags($string));
        $string = ltrim(rtrim($string));
        $string = substr($string, 0, $char);
        $string = substr($string, 0, strrpos($string, ' '));
        return $string;
    }
}