Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce get_excerpt_length() #3367

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -3994,17 +3994,7 @@ function wp_trim_excerpt( $text = '', $post = null ) {
add_filter( 'the_content', 'wp_filter_content_tags', 12 );
}

/* translators: Maximum number of words used in a post excerpt. */
$excerpt_length = (int) _x( '55', 'excerpt_length' );

/**
* Filters the maximum number of words in a post excerpt.
*
* @since 2.7.0
*
* @param int $number The maximum number of words. Default 55.
*/
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );
$excerpt_length = get_excerpt_length();

/**
* Filters the string in the "more" link displayed after a trimmed excerpt.
Expand All @@ -4029,6 +4019,28 @@ function wp_trim_excerpt( $text = '', $post = null ) {
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
}

/**
* Returns the excerpt length.
*
* @return int The excerpt length.
*/
function get_excerpt_length() {

/* translators: Maximum number of words used in a post excerpt. */
$excerpt_length = (int) _x( '55', 'excerpt_length' );

/**
* Filters the maximum number of words in a post excerpt.
*
* @since 2.7.0
*
* @param int $number The maximum number of words. Default 55.
*/
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );

return $excerpt_length;
}

/**
* Trims text to a certain number of words.
*
Expand Down
Loading