예제 #1
0
function truncate_to_n_words($text, $number_of_words, $url, $readmore = 'read more')
{
    $text = strip_tags($text);
    $excerpt = first_n_words($text, $number_of_words);
    if (str_word_count($text) !== str_word_count($excerpt)) {
        $excerpt .= '... <a href="' . $url . '">' . $readmore . '</a>';
    }
    return $excerpt;
}
예제 #2
0
function truncate_to_n_words($text, $number_of_words, $url, $readmore = 'Read More')
{
    $text = strip_tags($text);
    $excerpt = first_n_words($text, $number_of_words);
    // we can't just look at the length or try == because we strip carriage returns
    if (str_word_count($text) !== str_word_count($excerpt)) {
        $excerpt .= '... <br><a href="' . $url . '">' . $readmore . '</a>';
    }
    return $excerpt;
}
예제 #3
0
function first_n_text($text, $n)
{
    if (!isset($lang) || empty($lang)) {
        global $mt;
        $lang = $blog && $blog['blog_language'] ? $blog['blog_language'] : $mt->config('DefaultLanguage');
    }
    if ($lang == 'jp') {
        $lang = 'ja';
    }
    if ($lang == 'ja') {
        $text = strip_tags($text);
        $text = preg_replace('/\\r?\\n/', " ", $text);
        return substr_text($text, 0, $n);
    } else {
        return first_n_words($text, $n);
    }
}