function excerpt($excerpt = '', $length = '') { // Save a copy of the raw excerpt $raw_excerpt = $excerpt; // Excerpt length default if (empty($length)) { $length = absint(option('excerpt_length')); } // Generate an excerpt where none exists if (empty($excerpt)) { $post = get_post(); if (empty($post)) { return; } // Don't return an excerpt for a protected post if (post_password_required($post->ID)) { return esc_html__('This post is protected.', 'ubik'); } // Post contents will serve as the basis for generating the excerpt $excerpt = $post->post_content; } // Sanitize excerpt $excerpt = apply_filters('ubik_excerpt_sanitize', wptexturize(\Ubik\text_truncate($excerpt, $length, esc_html(option('excerpt_more'))))); // Run the excerpt through a filter on the way out the door return apply_filters('ubik_excerpt', $excerpt, $raw_excerpt); }
function 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_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 = absint(apply_filters('ubik_seo_meta_length', 80)); $ending = esc_html(apply_filters('ubik_seo_meta_ending', $ending)); // Truncate with internal Ubik function $desc = \Ubik\text_truncate($desc, $length, $ending); // Filter the results and return return apply_filters('ubik_seo_meta_sanitize_after', $desc); }