Пример #1
0
function ubik_excerpt_sanitize($excerpt = '', $length = '')
{
    // Exit early if this function does not receive any text
    if (empty($excerpt)) {
        return;
    }
    // Excerpt length and ending; these can be configured or filtered as needed
    $more = apply_filters('ubik_excerpt_more', _x('...', 'excerpt ending', 'ubik'));
    // … is also an option but it causes problems in some contexts
    // Truncate with Ubik Text
    $excerpt = ubik_text_truncate($excerpt, $length, $more);
    // Beautify excerpts since they'll end up back on the screen
    $excerpt = wptexturize($excerpt);
    // Send it back
    return apply_filters('ubik_excerpt_sanitize', $excerpt);
}
function ubik_seo_meta_description_sanitize($desc = '')
{
    // Provide an opportunity to filter the incoming description and return early if no text was provided
    $desc = apply_filters('ubik_seo_meta_description_sanitize_before', $desc);
    if (empty($desc)) {
        return;
    }
    // For the sake of simplicity; you could also use …
    if (preg_match('/^utf\\-?8$/i', get_option('blog_charset'))) {
        $ending = _x('…', 'meta description ending', 'ubik');
    } else {
        $ending = _x('...', 'meta description ending', 'ubik');
    }
    // Excerpt length and ending; these can be set in ubik-config.php
    $length = (int) apply_filters('ubik_seo_meta_description_length', 80);
    $ending = (string) apply_filters('ubik_seo_meta_description_ending', $ending);
    // Truncate with Ubik Text
    $desc = ubik_text_truncate($desc, $length, $ending);
    // Filter the results and return
    return apply_filters('ubik_seo_meta_description_sanitize', $desc);
}