Show more link in RSS. Don't show more link if more link text empty. Take more into account when creating excerpt.

git-svn-id: http://svn.automattic.com/wordpress/trunk@4184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-09-11 23:59:00 +00:00
parent 0eeccc10e9
commit f666759471
3 changed files with 10 additions and 6 deletions

View File

@ -741,7 +741,7 @@ function human_time_diff( $from, $to = '' ) {
function wp_trim_excerpt($text) { // Fakes an excerpt if needed function wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $post; global $post;
if ( '' == $text ) { if ( '' == $text ) {
$text = $post->post_content; $text = get_the_content('');
$text = apply_filters('the_content', $text); $text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text); $text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text); $text = strip_tags($text);

View File

@ -82,7 +82,7 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
$content = $pages[$page-1]; $content = $pages[$page-1];
if ( preg_match('/<!--more(.+?)?-->/', $content, $matches) ) { if ( preg_match('/<!--more(.+?)?-->/', $content, $matches) ) {
$content = explode($matches[0], $content, 2); $content = explode($matches[0], $content, 2);
if ( !empty($matches[1]) ) if ( !empty($matches[1]) && !empty($more_link_text) )
$more_link_text = strip_tags(wp_kses_no_null(trim($matches[1]))); $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
} else { } else {
$content = array($content); $content = array($content);
@ -94,10 +94,14 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
$teaser = ''; $teaser = '';
$output .= $teaser; $output .= $teaser;
if ( count($content) > 1 ) { if ( count($content) > 1 ) {
if ( $more ) if ( $more ) {
$output .= '<a id="more-'.$id.'"></a>'.$content[1]; $output .= '<a id="more-'.$id.'"></a>'.$content[1];
else } else {
$output = balanceTags($output . ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>"); $output = balanceTags($output);
if ( ! empty($more_link_text) )
$output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";
}
} }
if ( $preview ) // preview fix for javascript bug with foreign languages 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); $output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);

View File

@ -42,7 +42,7 @@ $more = 1;
<?php else : ?> <?php else : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description> <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php if ( strlen( $post->post_content ) > 0 ) : ?> <?php if ( strlen( $post->post_content ) > 0 ) : ?>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded> <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
<?php else : ?> <?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?> <?php endif; ?>