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.


Built from https://develop.svn.wordpress.org/branches/5.0@43858


git-svn-id: http://core.svn.wordpress.org/branches/5.0@43687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-11-01 05:20:47 +00:00
parent 6ad646a080
commit e0664765b6
2 changed files with 4 additions and 4 deletions

View File

@ -639,7 +639,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.
@ -649,7 +649,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.
@ -659,7 +659,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

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-beta2-43857';
$wp_version = '5.0-beta2-43858';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.