From dab0d4043674d9521d3717eb0f74f12c2f74eaff Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Mon, 17 Dec 2018 18:06:42 +0000 Subject: [PATCH] Block Editor: Fix PHP warning when loading editor styles while in RTL. In RTL languages, WordPress adds `style-editor-rtl.css` editor styles to the global `$editor_styles`. This patch ignores handling these styles if the file is not preset. Also, clarify the docs for the return value of the `block_version` function. Props mostafa.s1990, desrosj, mukesh27. Merges [43923] and [43924] to trunk. Fixes #45288, #45342. git-svn-id: https://develop.svn.wordpress.org/trunk@44270 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-blocks.php | 12 +++++++----- src/wp-includes/blocks.php | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 8dc7da46f4..bc01ea11e4 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -197,11 +197,13 @@ if ( $editor_styles && current_theme_supports( 'editor-styles' ) ) { ); } } else { - $file = get_theme_file_path( $style ); - $styles[] = array( - 'css' => file_get_contents( get_theme_file_path( $style ) ), - 'baseURL' => get_theme_file_uri( $style ), - ); + $file = get_theme_file_path( $style ); + if ( file_exists( $file ) ) { + $styles[] = array( + 'css' => file_get_contents( $file ), + 'baseURL' => get_theme_file_uri( $style ), + ); + } } } } diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index e584dc377d..fe1cb685ee 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -283,7 +283,7 @@ function _restore_wpautop_hook( $content ) { * @since 5.0.0 * * @param string $content Content to test. - * @return int The block format version. + * @return int The block format version is 1 if the content contains one or more blocks, 0 otherwise. */ function block_version( $content ) { return has_blocks( $content ) ? 1 : 0;