From 792c3035ca900314fad7ab8afae3486ed9951329 Mon Sep 17 00:00:00 2001 From: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com> Date: Tue, 7 Dec 2021 01:27:31 +0100 Subject: [PATCH] Refactor the `gutenberg_is_fse_theme` function to use `wp_is_block_theme` (#37161) * Rename wp_is_block_template_theme to wp_is_block_theme * Use wp_is_block_theme (if it's available). Add a note about future deprecation of the gutenberg_is_fse_theme function. --- lib/compat/wordpress-5.9/template-parts.php | 4 ++-- lib/compat/wordpress-5.9/templates.php | 4 ++-- lib/full-site-editing/full-site-editing.php | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/compat/wordpress-5.9/template-parts.php b/lib/compat/wordpress-5.9/template-parts.php index 1d84d00afbe48a..a095bbe6643e05 100644 --- a/lib/compat/wordpress-5.9/template-parts.php +++ b/lib/compat/wordpress-5.9/template-parts.php @@ -12,8 +12,8 @@ */ // Only run any of the code in this file if the version is less than 5.9. -// wp_is_block_template_theme was introduced in 5.9. -if ( ! function_exists( 'wp_is_block_template_theme' ) ) { +// wp_is_block_theme was introduced in 5.9. +if ( ! function_exists( 'wp_is_block_theme' ) ) { /** * Registers block editor 'wp_template_part' post type. */ diff --git a/lib/compat/wordpress-5.9/templates.php b/lib/compat/wordpress-5.9/templates.php index 93b8c40a8c0cf2..c6f41eff9c9d66 100644 --- a/lib/compat/wordpress-5.9/templates.php +++ b/lib/compat/wordpress-5.9/templates.php @@ -12,8 +12,8 @@ */ // Only run any of the code in this file if the version is less than 5.9. -// wp_is_block_template_theme was introduced in 5.9. -if ( ! function_exists( 'wp_is_block_template_theme' ) ) { +// wp_is_block_theme was introduced in 5.9. +if ( ! function_exists( 'wp_is_block_theme' ) ) { /** * Registers block editor 'wp_template' post type. */ diff --git a/lib/full-site-editing/full-site-editing.php b/lib/full-site-editing/full-site-editing.php index 8320d1b32ccb3b..9e04a8388d2671 100644 --- a/lib/full-site-editing/full-site-editing.php +++ b/lib/full-site-editing/full-site-editing.php @@ -8,9 +8,17 @@ /** * Returns whether the current theme is an FSE theme or not. * + * Note: once 5.9 is the minimum supported WordPress version for the Gutenberg + * plugin, we must deprecate this function and + * use wp_is_block_theme instead. + * * @return boolean Whether the current theme is an FSE theme or not. */ function gutenberg_is_fse_theme() { + if ( function_exists( 'wp_is_block_theme' ) ) { + return wp_is_block_theme(); + } + return is_readable( get_theme_file_path( '/block-templates/index.html' ) ) || is_readable( get_theme_file_path( '/templates/index.html' ) ); }