mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-12 06:43:20 +01:00
Make excerpt stuff a filter
git-svn-id: http://svn.automattic.com/wordpress/trunk@2341 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1d6d4c6d93
commit
067e48e161
@ -71,6 +71,8 @@ add_filter('the_excerpt', 'convert_smilies');
|
||||
add_filter('the_excerpt', 'convert_chars');
|
||||
add_filter('the_excerpt', 'wpautop');
|
||||
|
||||
add_filter('get_the_excerpt', 'wp_trim_excerpt');
|
||||
|
||||
add_filter('sanitize_title', 'sanitize_title_with_dashes');
|
||||
|
||||
add_action('publish_post', 'generic_ping');
|
||||
|
@ -642,4 +642,28 @@ function human_time_diff( $from, $to = '' ) {
|
||||
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
|
||||
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;
|
||||
return apply_filters('get_the_excerpt', $output);
|
||||
}
|
||||
|
||||
function wp_link_pages($args = '') {
|
||||
|
Loading…
Reference in New Issue
Block a user