Пример #1
0
function otf_excerpt($option_key, $result, $ext)
{
    if (!$ext) {
        $len = 55;
        $type = 'a';
    } else {
        $s = explode(':', $ext);
        if (count($s) == 1) {
            $s[] = 'a';
        }
        $len = $s[0];
        $type = $s[1];
        if ($type === 'b') {
            if (count($s) > 2) {
                $more = $s[2];
            } else {
                $more = ' …';
            }
            if (count($s) > 3) {
                if ($s[3] === 'link') {
                    $url = otf_url($option_key, $result, '');
                    $more = '<a href="' . $url . '">' . $more . '</a>';
                }
            }
            if (count($s) > 4) {
                $numsent = $s[4];
            }
        }
    }
    switch ($type) {
        case 'a':
            $value = trim($result->post_excerpt);
            if ($value == '') {
                $value = $result->post_content;
            }
            $value = oth_trim_excerpt($value, $ext);
            break;
        case 'b':
            $value = trim($result->post_excerpt);
            if ($value === '') {
                $value = $result->post_content;
                $value = convert_smilies($value);
                $value = oth_trim_extract($value, $len, $more, $numsent);
                $value = apply_filters('get_the_content', $value);
                remove_filter('the_content', 'ppl_content_filter', 5);
                remove_filter('the_content', 'ppl_post_filter', 5);
                $value = apply_filters('the_content', $value);
                add_filter('the_content', 'ppl_content_filter', 5);
                add_filter('the_content', 'ppl_post_filter', 5);
            } else {
                $value = convert_smilies($value);
                $value = apply_filters('get_the_excerpt', $value);
                remove_filter('the_excerpt', 'ppl_content_filter', 5);
                $value = apply_filters('the_excerpt', $value);
                add_filter('the_excerpt', 'ppl_content_filter', 5);
            }
            break;
        default:
            $value = trim($result->post_excerpt);
            if ($value == '') {
                $value = $result->post_content;
            }
            $value = oth_trim_excerpt($value, $len);
            break;
    }
    return $value;
}
Пример #2
0
function otf_excerpt($option_key, $result, $ext)
{
    if (!$ext) {
        $len = 55;
        $type = 'a';
    } else {
        $s = explode(':', $ext);
        if (count($s) == 1) {
            $s[] = 'a';
        }
        $len = $s[0];
        $type = $s[1];
        if ($type === 'b') {
            if (count($s) > 2) {
                $more = $s[2];
            } else {
                $more = ' &hellip;';
            }
        }
    }
    switch ($type) {
        case 'a':
            $value = trim($result->post_excerpt);
            if ($value == '') {
                $value = $result->post_content;
            }
            $value = oth_trim_excerpt($value, $ext);
            break;
        case 'b':
            $value = trim($result->post_excerpt);
            if ($value === '') {
                $value = $result->post_content;
                $value = convert_smilies($value);
                $value = oth_trim_extract($value, $len, $more);
                $value = apply_filters('get_the_content', $value);
                $value = apply_filters('the_content', $value);
            } else {
                $value = convert_smilies($value);
                $value = apply_filters('get_the_excerpt', $value);
                $value = apply_filters('the_excerpt', $value);
            }
            break;
        default:
            $value = trim($result->post_excerpt);
            if ($value == '') {
                $value = $result->post_content;
            }
            $value = oth_trim_excerpt($value, $len);
            break;
    }
    return $value;
}