Skip to content

Commit fe56c5d

Browse files
committed
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. Props dd32. See #45236. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43858 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 12f0039 commit fe56c5d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/wp-admin/includes/post.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
639639
* @param string $post_content Default post content.
640640
* @param WP_Post $post Post object.
641641
*/
642-
$post->post_content = apply_filters( 'default_content', $post_content, $post );
642+
$post->post_content = (string) apply_filters( 'default_content', $post_content, $post );
643643

644644
/**
645645
* Filters the default post title initially used in the "Write Post" form.
@@ -649,7 +649,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
649649
* @param string $post_title Default post title.
650650
* @param WP_Post $post Post object.
651651
*/
652-
$post->post_title = apply_filters( 'default_title', $post_title, $post );
652+
$post->post_title = (string) apply_filters( 'default_title', $post_title, $post );
653653

654654
/**
655655
* Filters the default post excerpt initially used in the "Write Post" form.
@@ -659,7 +659,7 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
659659
* @param string $post_excerpt Default post excerpt.
660660
* @param WP_Post $post Post object.
661661
*/
662-
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
662+
$post->post_excerpt = (string) apply_filters( 'default_excerpt', $post_excerpt, $post );
663663

664664
return $post;
665665
}

0 commit comments

Comments
 (0)