From 7f2a7a3f3ea747dde28c561b82801df7cc29b7d1 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 16 Dec 2018 01:58:41 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@44224 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/post.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 31e1a1559e..48caefa4d9 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -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; }