Skip to content

Commit

Permalink
Refactor the gutenberg_is_fse_theme function to use `wp_is_block_th…
Browse files Browse the repository at this point in the history
…eme` (#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.
  • Loading branch information
anton-vlasenko authored Dec 7, 2021
1 parent 7129e1a commit 792c303
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/compat/wordpress-5.9/template-parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/compat/wordpress-5.9/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
8 changes: 8 additions & 0 deletions lib/full-site-editing/full-site-editing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand Down

0 comments on commit 792c303

Please sign in to comment.