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
This commit is contained in:
Jonathan Desrosiers
2018-12-17 18:06:42 +00:00
parent 2ae5bb324d
commit dab0d40436
2 changed files with 8 additions and 6 deletions

View File

@@ -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 ),
);
}
}
}
}

View File

@@ -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;