Make excerpt stuff a filter
git-svn-id: https://develop.svn.wordpress.org/trunk@2341 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fe2c881868
commit
9b6518f605
|
@ -71,6 +71,8 @@ add_filter('the_excerpt', 'convert_smilies');
|
||||||
add_filter('the_excerpt', 'convert_chars');
|
add_filter('the_excerpt', 'convert_chars');
|
||||||
add_filter('the_excerpt', 'wpautop');
|
add_filter('the_excerpt', 'wpautop');
|
||||||
|
|
||||||
|
add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
||||||
|
|
||||||
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
||||||
|
|
||||||
add_action('publish_post', 'generic_ping');
|
add_action('publish_post', 'generic_ping');
|
||||||
|
|
|
@ -642,4 +642,28 @@ function human_time_diff( $from, $to = '' ) {
|
||||||
return $since;
|
return $since;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_trim_excerpt( $text ) { // Fakes an excerpt if needed
|
||||||
|
global $post;
|
||||||
|
if ( '' == $text ) {
|
||||||
|
$text = $post->post_content;
|
||||||
|
$text = strip_tags( $text );
|
||||||
|
$blah = explode(' ', $text);
|
||||||
|
$excerpt_length = 55;
|
||||||
|
if (count($blah) > $excerpt_length) {
|
||||||
|
$k = $excerpt_length;
|
||||||
|
$use_dotdotdot = 1;
|
||||||
|
} else {
|
||||||
|
$k = count($blah);
|
||||||
|
$use_dotdotdot = 0;
|
||||||
|
}
|
||||||
|
$excerpt = '';
|
||||||
|
for ($i=0; $i<$k; $i++) {
|
||||||
|
$excerpt .= $blah[$i].' ';
|
||||||
|
}
|
||||||
|
$excerpt .= ($use_dotdotdot) ? '[...]' : '';
|
||||||
|
$text = $excerpt;
|
||||||
|
} // end if no excerpt
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -118,27 +118,7 @@ function get_the_excerpt($fakeit = true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we haven't got an excerpt, make one in the style of the rss ones
|
return apply_filters('get_the_excerpt', $output);
|
||||||
if (($output == '') && $fakeit) {
|
|
||||||
$output = $post->post_content;
|
|
||||||
$output = strip_tags($output);
|
|
||||||
$blah = explode(' ', $output);
|
|
||||||
$excerpt_length = 70;
|
|
||||||
if (count($blah) > $excerpt_length) {
|
|
||||||
$k = $excerpt_length;
|
|
||||||
$use_dotdotdot = 1;
|
|
||||||
} else {
|
|
||||||
$k = count($blah);
|
|
||||||
$use_dotdotdot = 0;
|
|
||||||
}
|
|
||||||
$excerpt = '';
|
|
||||||
for ($i=0; $i<$k; $i++) {
|
|
||||||
$excerpt .= $blah[$i].' ';
|
|
||||||
}
|
|
||||||
$excerpt .= ($use_dotdotdot) ? '...' : '';
|
|
||||||
$output = $excerpt;
|
|
||||||
} // end if no excerpt
|
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_link_pages($args = '') {
|
function wp_link_pages($args = '') {
|
||||||
|
|
Loading…
Reference in New Issue