diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 4c491c416c..35f356982c 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -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'); diff --git a/wp-includes/functions-formatting.php b/wp-includes/functions-formatting.php index d0ba110e14..9f977970f3 100644 --- a/wp-includes/functions-formatting.php +++ b/wp-includes/functions-formatting.php @@ -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; +} + ?> \ No newline at end of file diff --git a/wp-includes/template-functions-post.php b/wp-includes/template-functions-post.php index 6e5a21da38..1b6ace90f1 100644 --- a/wp-includes/template-functions-post.php +++ b/wp-includes/template-functions-post.php @@ -104,41 +104,21 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_ } function the_excerpt() { - echo apply_filters('the_excerpt', get_the_excerpt()); + echo apply_filters('the_excerpt', get_the_excerpt()); } function get_the_excerpt($fakeit = true) { - global $id, $post; - $output = ''; - $output = $post->post_excerpt; - if (!empty($post->post_password)) { // if there's a password - if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie - $output = __('There is no excerpt because this is a protected post.'); - return $output; - } - } + global $id, $post; + $output = ''; + $output = $post->post_excerpt; + if (!empty($post->post_password)) { // if there's a password + if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie + $output = __('There is no excerpt because this is a protected post.'); + return $output; + } + } - // 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 = '') {