From fb10a6c04c5951bf97991dcbffbd126f5b25438c Mon Sep 17 00:00:00 2001 From: Mike Little Date: Tue, 6 May 2003 22:15:28 +0000 Subject: [PATCH] Added return excerpt if none git-svn-id: https://develop.svn.wordpress.org/trunk@17 602fd350-edb4-49c9-b593-d223f7449a82 --- b2-include/b2template.functions.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 23f8137d8f..234e322520 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -413,6 +413,7 @@ function the_excerpt_rss($cut = 0, $encode_html = 0) { } echo $excerpt; } + function the_excerpt_unicode() { $excerpt = get_the_excerpt(); $excerpt = convert_bbcode($excerpt); @@ -422,20 +423,38 @@ function the_excerpt_unicode() { $excerpt = apply_filters('the_excerpt_unicode', $excerpt); echo $excerpt; } + function get_the_excerpt() { global $id,$postdata; global $HTTP_SERVER_VARS, $preview; $output = ''; $output = $postdata['Excerpt']; + //if we haven't got an excerpt, make one in the style of the rss ones + if ($output == '') { + $output = get_the_content(); + $output = strip_tags($output); + $blah = explode(' ', $output); + $excerpt_length = 120; + if (count($blah) > $excerpt_length) { + $k = $excerpt_length; + $use_dotdotdot = 1; + } else { + $k = count($blah); + $use_dotdotdot = 0; + } + for ($i=0; $i<$k; $i++) { + $excerpt .= $blah[$i].' '; + } + $excerpt .= ($use_dotdotdot) ? '...' : ''; + $output = $excerpt; + } // end if no excerpt if ($preview) { // preview fix for javascript bug with foreign languages $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output); } - return($output); + return $output; } - - function link_pages($before='
', $after='
', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { global $id,$page,$numpages,$multipage,$more; global $pagenow;