Editor: Cast the result of the default_content, default_title, and default_excerpt filters.

If a plugin returns a non-string value (or returns `null`) on these filters, it can cause errors in the block editor. Casting them as a string prevents these errors.

Merges [43858] from the 5.0 branch to trunk.

Props dd32.
See #45236.

Built from https://develop.svn.wordpress.org/trunk@44224


git-svn-id: http://core.svn.wordpress.org/trunk@44054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2018-12-17 03:04:29 +00:00
parent 7b58ca24e3
commit 7ffb7340f5
2 changed files with 4 additions and 4 deletions

View File

@ -683,7 +683,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
* @param string $post_content Default post content.
* @param WP_Post $post Post object.
*/
$post->post_content = apply_filters( 'default_content', $post_content, $post );
$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );
/**
* Filters the default post title initially used in the "Write Post" form.
@ -693,7 +693,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
* @param string $post_title Default post title.
* @param WP_Post $post Post object.
*/
$post->post_title = apply_filters( 'default_title', $post_title, $post );
$post->post_title = (string) apply_filters( 'default_title', $post_title, $post );
/**
* Filters the default post excerpt initially used in the "Write Post" form.
@ -703,7 +703,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
* @param string $post_excerpt Default post excerpt.
* @param WP_Post $post Post object.
*/
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
$post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post );
return $post;
}

View File

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