Posts, Post Types: In wp_trim_words() make sure the $num_words parameter is always an integer, as documented, to avoid a PHP warning.

Props donmhico, pikamander2.
Fixes #47867.
Built from https://develop.svn.wordpress.org/trunk@45796


git-svn-id: http://core.svn.wordpress.org/trunk@45607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-14 17:18:55 +00:00
parent ae4087bca6
commit c03a0bea8d
2 changed files with 3 additions and 2 deletions

View File

@ -3728,7 +3728,7 @@ function wp_trim_excerpt( $text = '', $post = null ) {
* *
* @param int $number The maximum number of words. Default 55. * @param int $number The maximum number of words. Default 55.
*/ */
$excerpt_length = apply_filters( 'excerpt_length', $excerpt_length ); $excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );
/** /**
* Filters the string in the "more" link displayed after a trimmed excerpt. * Filters the string in the "more" link displayed after a trimmed excerpt.
@ -3773,6 +3773,7 @@ function wp_trim_words( $text, $num_words = 55, $more = null ) {
$original_text = $text; $original_text = $text;
$text = wp_strip_all_tags( $text ); $text = wp_strip_all_tags( $text );
$num_words = (int) $num_words;
/* /*
* translators: If your word count is based on single characters (e.g. East Asian characters), * translators: If your word count is based on single characters (e.g. East Asian characters),

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3-alpha-45795'; $wp_version = '5.3-alpha-45796';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.